tag:support.nodebox.net,2012-11-01:/discussions/show-your-work/719-triangle-formulasNodeBox: Discussion 2024-03-12T06:25:23Ztag:support.nodebox.net,2012-11-01:Comment/617381522024-03-12T06:14:18Z2024-03-12T06:25:23ZTriangle Formulas<div><p>My triangle node is a hidden gem of the Cartan Node Library.</p>
<p>It's deceptively simple. Just provide three values (2 angles and a side, an angle and 2 sides, or 3 sides) and my node will calculate the only possible triangle with those values. You can show just the triangle, the triangle with labels, or the six values (3 angles and 3 sides).</p>
<p>Triangle is surprisingly useful - not just for drawing triangles but also for figuring out how to draw many other things. The triangle node is a miniature trigonometry teacher. It can help you figure out where to place things and how to size them precisely. If you can supply three values (angles or edge lengths) that you know, it will give you three other values that you need. By setting the show option to "Values" and using a slice node, you can then retrieve whichever value you need.</p>
<p>Sometimes, though, I want to pass my known values as parameters that change over time (as in an animation) and calculate the missing values directly without having to create a proxy triangle and slice values. I just want to know the trigonometric formulas the triangle uses. I could go on the web and search for those formulas (and I have, many times), but they are bit hard to pull up in the form I need and a tad confusing to apply. I have often wished that my triangle node could just tell me what formulas it is using in a particular situation.</p>
<p>Now my wish has been granted!</p>
<p>Version 3.4 of the triangle node now has a new show option: formulas. If you select this option, triangle will draw and label the triangle and then list the formulas it used below the diagram. It shows the three supplied values in color (blue for angles, red for sides), and then reveals the formulas used for the other three values. (See screenshot.)</p>
<p>There are 19 different ways to supply three values including at least one side, so there are 19 combinations of formulas - 57 specific variations in all. Each formula is fairly easy to turn into a Nodebox function. Some formulas do require arcsin or arccos, but both are available in my library (arcsin is hidden inside the library demo for the arccos node).</p>
<p>You can see the power of this new feature by fiddling with the triangle parameters. Scrub any of the supplied values to see both triangle and formulas update. Then change which three values you supply (set unknowns to zero) and see what new formulas appear. You can learn a lot about trigonometry just by playing with this one node.</p>
<p>I also fixed two other minor bugs in the update.</p>
<ul>
<li>Values mode now shows the six values in the same order they are entered (A, B, C, AB, AC, BC).</li>
<li>Invalid triangles now show an error message in all view modes (even in values mode)</li>
</ul>
<p>This new formula option is something I've wanted to do for years, but it was rather hard to do. It's one thing for a node to do complicated things, but quite another for it to explain HOW it did each possible complicated thing. I finally figured out a way to do it.</p>
<p>I realize that I may be the only one to ever use this feature. So this is a gift to myself. But all of you are free to enjoy it as well. I would be tickled to hear any comments.</p></div>john