Sub_Path and Find_T

john's Avatar

john

15 Jan, 2025 06:37 AM

Attached are the first additions to what will be v3.6 of my node library: an update to sub_path and a new node - find_T.

Sub_path returns a portion of a complex path between two percentages: Start and End. The original version assumed Start was less than End. This is fine for open paths like a line segment, but for closed paths, like a circle, it could be very handy to continue around and return a subpath between, say, a Start at 80% and and End at 23%.

The updated version of sub_path now allows this. It also allows another trick: setting Start and End to the same value. If you do this for a closed path it will return the complete path but starting at the specified point. If you are making a clock (as we will see in a moment), you might want your circle to start at the 12 o'clock position instead of the default 3 o'clock position. Feeding a circle into sub_path with Start and End both set to 75 will now do this.

(For circles you could do the same thing by simply rotating it, but for more complex shapes this is not the case.)

Find_T finds the T percentage point in a path closest to a given point. This is handy in situations where you have the coordinates of a certain point in a path and need to know what T value that corresponds with. Point_on_path and a number of my nodes require such T values - including sub_path.

The attached demo shows a somewhat contrived but amusing example where both of these nodes are needed.

Suppose you wanted to make a clock out of an odd shape, say a Reuleaux Triangle. And suppose that shape was slowly rotating. How would you arrange the 12 hours around this shape so that 12 was always due north of center?

You can find that due north of center point using my intersct_path node. Just make a line traveling north from center (-90 degrees) and get the intersection point. Now you just need to shift the path so that it starts at that point.

Find_T to the rescue! Give it the path and the point and it will return the T value even with a rotating shape. Then you can plug that value into both Start and End of the updated sub_path node to shift the path so that it always starts at the 12 o'clock position. You can then use a resample node to easily arrange the 12 hours around the shape.

Now let's add an even odder challenge. Let's outline in red the portion of the clock between the minute hand and the hour hand. If it was, say, 6:15, with the minute hand 25% of the way around the clock, and the hour hand at about 54%, the old sub_path node would have handled that and returned a little over a quarter of the path.

But what would happen at, say, 6:36? The hour hand is now at 55% but the minute hand is at 60%. Now Start is greater then End. Now we want a clockwise (of course) path starting at 60% continuing around the top and coming back almost all the way around to 55%. And that is what you will now get with the updated sub_path node!

All of this will make more sense once you look at the screenshot and the short movie of the clock. It's rather mesmerizing. In fact, I posted a fancier version of this clock on my Instagram page.

Find_T is a node I've needed from time to time and finally decided to add to my library. The improvement to sub_path is something I needed for a cool new node, which I will be publishing shortly, but will be useful in many other situations as well.

For added fun, you can change the clock shape in the symbol node to a heart. The heart is a bit messy because, at certain points in its rotation, the minute hand protrudes outside the heart. The diamond also makes an interesting clock, but the spade and club are too complex and will fall apart at various points (when the due north starting line returns multiple intersection points). Give it a try!

Reply to this discussion

Internal reply

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

Attaching KB article:

»

Already uploaded files

  • find_T_sub_path_screenshot.png 598 KB
  • find_t_demo_clock.mp4 990 KB
  • findT_demo.ndbx.zip 86.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

06 Feb, 2025 01:37 AM
04 Feb, 2025 06:32 AM
04 Feb, 2025 05:04 AM
30 Jan, 2025 09:31 AM
30 Jan, 2025 09:08 AM

 

30 Jan, 2025 08:40 AM
24 Jan, 2025 07:50 AM
22 Jan, 2025 11:42 PM
21 Jan, 2025 09:43 AM
21 Jan, 2025 09:41 AM
21 Jan, 2025 09:36 AM