Triangle Node

john's Avatar

john

08 Feb, 2021 04:03 AM

The three most common and elementary shapes are the circle, the square, and the triangle. For circles NodeBox provides the ellipse node, for squares the rect node. You can make only equilateral triangles with the polygon node. What about scalene triangles, right triangles, obtuse and acute triangles? I have often wondered: why doesn't NodeBox provide a general purpose triangle node?

When I finally sat down to make one myself, I learned why. Triangles are tricky. They are subtle and complex, full of weird corner cases. There are 57 different calculations required for a general purpose node, some involving trigonometric nodes NodeBox doesn't supply, like arcsin and arccos. Even just crafting a coherent UI to specify a triangle is challenging. In fact, this is one of the most challenging nodes I've ever made.

But it's also one of the most fun nodes to play with.

My triangle node has seven parameters:

  • Angle A
  • Angle B
  • Angle C
  • Side AB
  • Side AC
  • Side BC
  • A checkbox option to show labels

The triangle you create sits on the X axis with Angle A sitting on the origin; Angle B is to its right and Angle C is on top. (Of course once you make your triangle, you can move it, rotate it and scale it to your heart's content.)

To create a triangle you must supply exactly three of the first six values, one of which must be a side: two angles and a side, one angle and two sides, or just three sides. If you enter more or less than three non-zero values, or forget to include at least one side, the node will display a reminder message. Swipe left on all six fields to reset.

Most combinations of values work fine. But if you provide two angles which sum to 180 degrees or more, or if you enter some other combination of values that cannot be used to create a valid triangle (like a leg longer than its hypotenuse) you will also see a message. There are also some cases in which the specified values could result in two different triangles; in those cases, the node will pick one for you.

When creating your triangle it may be helpful to temporarily turn on the labels to easily see all the sides and angles. The labels are automatically positioned and sized to maximum legibility.

As an added bonus, I have also included two "satellite nodes" which may come in handy:

  • Tri_center provides the true centroid of a triangle. NodeBox's centroid node is based on the rectangular bounds enclosing the triangle, so is often nowhere near the actual center. Tri_center fills that gap.
  • In_circle returns the largest circle that can be inscribed in a given triangle. It also works for regular polygons with more than 3 sides.

To see the triangle, tri_center, and in_circle nodes in action, check out this video. The black dot is the NodeBox centroid, the red dot the true centroid, and the circle is the inscribed circle which changes with its triangle:

https://www.instagram.com/p/CK_TysoHttF/

Please give this node a try and report back if you have any questions, malfunctions, or rave reviews. It's fun seeing the triangle instantly respond with every turn of any one of the six dials.

Go forth and create!

John

  1. Support Staff 1 Posted by john on 17 Feb, 2021 09:27 AM

    john's Avatar

    Attached is an updated version of the triangle node with a very minor improvement.

    The original node output a group whether or not labels were enabled. The new version outputs a group if labels are enabled, but a simple path if they are not.

    The demo now also shows the correct centers and incircle whether or not the labels are enabled.

    That's all.

  2. Support Staff 2 Posted by john on 05 Apr, 2021 10:39 AM

    john's Avatar

    Attached is a demo of an additional node useful for triangle jockeys.

    NOTE: See next comment for an update to this node.

    The label_triangle node takes any triangle and adds blue angle labels and red edge length labels. This is handy when you have a triangle and you just want to know its measurements. It saves you the trouble of extracting the points and feeding them into angle or distance nodes.

    The demo shows what it does to a random triangle generated by connecting three points from a scatter node. Change the scatter seed to try other random triangles.

    In addition to posting this demo, I will tuck this node inside the demo for the main triangle node in the next release of my node library.

    Enjoy!

    John

  3. Support Staff 3 Posted by john on 15 Apr, 2021 06:22 AM

    john's Avatar

    Attached is a slight update to the original version of the label_triangle node.

    This new version is exactly the same, except that the assignment of labels (A, B, and C) now follows the original point order of the triangle, regardless of the current rotation of the triangle.

    This doesn't matter much when labeling a single static triangle. But it is helpful when labeling a rotating triangle (which I actually did for a recent animation).

    John

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_node_screenshot.png 364 KB
  • triangle_node.zip 19.5 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

Generic

? 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

23 Jun, 2021 01:36 AM
20 Jun, 2021 07:19 AM
13 Jun, 2021 11:19 PM
06 Jun, 2021 09:27 AM
05 Jun, 2021 10:17 AM

 

05 Jun, 2021 07:45 AM
23 May, 2021 10:05 PM
23 May, 2021 10:02 PM
17 May, 2021 12:04 AM
16 May, 2021 01:00 PM
14 May, 2021 03:16 PM