3 ms·
> Make a triangle with side lengths 7,8, and 9. p, q, r = params("side1", "side2", "side3") pq = arccos((p^2+q^2-r^2)/(2*p*q)) pr = # ... similar
by OJFord 6y ago
> Make a triangle with side lengths 7,8, and 9.
p, q, r = params("side1", "side2", "side3")
pq = arccos((p^2+q^2-r^2)/(2*p*q))
pr = # ... similar
qr = # ... similar
assert pq + pr + qr == 360, "Side lengths invalid"
pside = line((0,0), (p,0))
xy_qr = (r*cos(180-pr), r*sin(180-pr))
qside = line((p,0), xy_qr)
rside = line(xy_qr, (0,0))
triangle = sketch(pside, qside, rside)
Or whatever this fictional API is to look like.
Obviously to do generic constraint solving, you need a generic constraint solver. My point is that if you have fixed known constraints, and a programming language, you can just compute what you want explicitly.