Extract Tangent Values from SOP for Chainlink Visual

Hello all,

I am trying to create a chain that follows a curve, line, etc. Right now I am using a circle SOP because it seems I can create tangent attributes. My thought is to use the tangent values to rotate the chains according to the curve input. The input curve sets the instancing, translation is taken care of. Rotation is split into having them alternate 90 deg which is done by a GLSL Top. I still need help on getting the right tangent values to have the chains “curve” to the input. Attached is my file.

chain_tangent_help.toe (136.1 KB)

Here is a diagram of what I’m trying to achieve.

Hi @lefk97,

you can calculate the tangent angle for each point by subtracting the following point from the previous point and taking the atan2(y,x) of the resulting vector.

With CHOPs you can use the SOP to CHOP and add an Extend CHOP setting the Left Behavior and Right Behavior parameters to “Slope” in order to calculate the first and last tangent. Now add a Shift CHOP and use the Scroll Offset parameter to shift all channels by “2” samples. What you now have is one CHOP with all “previous” point positions and one CHOP with all “following” point positions.
Subtract these from each other using a Math CHOP and via 2 Selects and a Function CHOP set to atan2, calculate the tangent angle. Now shift all channels by 1 sample and trim off the first and last samples before using this as a reference for the instancing’s rotate parameter.

I think the Attribute Create SOP’s Tangent parameter incorporate the Normals of the geometry, so for a default circle the normals are pointing perpendicular to the plane the circle is created in - in this case they point towards +z. For the circle this is easy but not really doable for an arbitrary line.

Hope this helps
cheers
Markus

This is fantastic worked extremely well! Thank you for the quick response and thorough solution. One thing I will have to tweak now is the first link in the chain, when animating, is a little off. I will see if I can just “hide” it for now, but this is because there is not another chain in front of it to correctly calculate tangent right?

Hi @lefk97,

Hmmmm - surprised that it looks wrong - have a look at my solution attached here to see what might be different…

cheers
Markus
chain_tangent_help.3.toe (135.3 KB)