triangle.py revision 9fefe969c78790b255996a6fa8ebe02c403761ba
'''
Copyright (C) 2007 John Beard john.j.beard@gmail.com
##This extension allows you to draw a triangle given certain information
## about side length or angles.
##Measurements of the triangle
C(x_c,y_c)
/`__
/ a_c``--__
/ ``--__ s_a
s_b / ``--__
/a_a a_b`--__
/--------------------------------``B(x_b, y_b)
A(x_a,y_a) s_b
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
import inkex
import simplestyle, sys
from math import *
def angle_from_3_sides(a, b, c): #return the angle opposite side c
if c_squared > 0:
else:
return 0 #means we have an invalid or degenerate triangle (zero is caught at the drawing stage)
return [x, y]
def is_valid_tri_from_sides(a,b,c):#check whether triangle with sides a,b,c is valid
return (a+b)>c and (a+c)>b and (b+c)>a and a > 0 and b> 0 and c>0#two sides must always be greater than the third
#no zero-length sides, no degenerate case
def draw_tri_from_3_sides(s_a, s_b, s_c, offset, parent): #draw a triangle from three sides (with a given offset
a = (0,0) #a is the origin
c[1] = -c[1]
else:
help="Side Length a")
help="Side Length b")
help="Side Length c")
help="Angle a")
help="Angle b")
help="Angle c")
help="Side Length c")
else:
else:
if not(error) and (a_b < pi) and (a_c < pi): #check that the solution is valid, if so draw acute solution
e = Grid_Polar()
e.affect()