Triangle Formulas

john's Avatar


12 Mar, 2024 06:14 AM

My triangle node is a hidden gem of the Cartan Node Library.

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).

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.

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.

Now my wish has been granted!

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.)

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).

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.

I also fixed two other minor bugs in the update.

  • Values mode now shows the six values in the same order they are entered (A, B, C, AB, AC, BC).
  • Invalid triangles now show an error message in all view modes (even in values mode)

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.

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.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Already uploaded files

  • triangle_formulas_screenshot.png 502 KB
  • 25.6 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

17 Jun, 2024 02:26 PM
15 Jun, 2024 01:44 PM
08 Jun, 2024 09:05 AM
08 Jun, 2024 09:00 AM
04 Jun, 2024 04:37 AM