 License New BSD license
 Lines 56
##### Keywords Nodebox (14) primitives (2) python (33) triangle (2)
##### Related Nodebox Community Nodebox Custom Primitives Nodebox Commands Tutorial, Flower Function Nodebox Animation Tutorial, Fluid Curve Movement Gears Graphical Path Filter
##### Permissions Owner: Theodore Test Group Owner: Nodebox Community Viewable by Everyone Editable by All Siafoo Users Siafoo is here to make coding less frustrating and to save you time.

# Triangle Primitives by Ideambulate 0

 In Brief Some Nodebox triangle primitives borrowed (with permission) from Ideambulate on the Nodebox Share site.... more
 Language Nodebox Python
# 's
` 1from utility_geometry import coordinates 2 3def equilateral_triangle(x0,y0,length,draw=True): 4    '''Draws an equilateral triangle.''' 5     6    x1,y1 = coordinates(x0,y0,length,0) 7    x2,y2 = coordinates(x0,y0,length,60) 8    beginpath(x0,y0) 9    lineto(x1,y1)10    lineto(x2,y2)11    lineto(x0,y0)12    p = endpath(draw)13    return p14    15def right_triangle(x0,y0,length1,length2,draw=True):16    '''Draws a right triangle, with the right angle at the origin'''17 18    x1,y1 = coordinates(x0,y0,length1,0)19    x2,y2 = coordinates(x0,y0,length2,90)20    beginpath(x0,y0)21    lineto(x1,y1)22    lineto(x2,y2)23    lineto(x0,y0)24    p = endpath(draw)25    return p26 27def isoscelestriangle(x0,y0,length,angle,draw=True):28    '''Draws an isosceles triangle defined by the length of the29    two equal sides and the angle between them.'''30    a = 180 - 2*angle31    x1,y1 = coordinates(x0,y0,length,0)32    x2,y2 = coordinates(x0,y0,length,a)33    beginpath(x0,y0)34    lineto(x1,y1)35    lineto(x2,y2)36    lineto(x0,y0)37    p = endpath(draw)38    return p39    40def scalenetriangle(x0,y0,length1,length2,angle,draw=True):41    '''Draws a scalene triange defined by the length of two sides42    and the angle between them.'''43    from math import radians, sin, cos,asin,degrees4445    a,c,angB = length1,length2,angle46    b = (a**2+c**2 - 2.0*a*c*cos(radians(angB)))**0.547    angA = degrees(asin((a*sin(radians(angB)))/b))48    angC = degrees(asin((c*sin(radians(angB)))/b))49 50    x1,y1 = coordinates(x0,y0,a,0)51    x2,y2 = coordinates(x0,y0,b,angC)52    53    beginpath(x0,y0)54    lineto(x1,y1)55    lineto(x2,y2)56    lineto(x0,y0)57    p = endpath(draw)58    return p`

Some Nodebox triangle primitives borrowed (with permission) from Ideambulate on the Nodebox Share site. 