Hello everyone
I would like to know if there is a way Dynamo can create a triangle from the lenght of its sides. If I have in data three numbers: 3,4,5, for example, can I draw a pythagorean triangle shape in a Dynamo model?
I’ve looking at this Python forum and an user asked how to create a triangle:
from turtle import color, begin_fill, forward, left, end_fill, done
from math import acos, degrees
def triangle_exists(a, b, c):
"""Return True iff there exists a triangle with sides a, b, c."""
return a + b > c and b + c > a and c + a > b
def triangle_angle(a, b, c):
"""Return the angle (in degrees) opposite the side of length a in the
triangle with sides a, b, c."""
# See http://en.wikipedia.org/wiki/Law_of_cosines
return degrees(acos((b ** 2 + c ** 2 - a ** 2) / (2.0 * b * c)))
def draw_triangle(a, b, c):
"""Draw a triangle with sides of lengths a, b, and c."""
assert(triangle_exists(a, b, c))
color('black', 'yellow')
begin_fill()
forward(c)
left(180 - triangle_angle(b, c, a))
forward(a)
left(180 - triangle_angle(c, a, b))
forward(b)
end_fill()
done()
>>> draw_triangle(400, 350, 200)
This is the code presented in the page I linked.
I would like to know if Dynamo can create geometries for triangles from code or if there exist nodes that help to do this.
Thanks in advance