4
$\begingroup$

in geometry nodes i want to determine which curves lies on the inside (our outside) of a turn. enter image description here

I found out that it should, in general, be possible to do so by calculating the curvature of of the curves and then comparing those values. The larger one should usually be the outside curve. My goal is to get and use these values as "mask" for further GN Stuff.

I base these two curves on one single bezier curve: enter image description here

Here i take my input curve and offset it by a factor in the normal direction, however i'm unsure about calculating the curvature and then comparing it. Does anyone have an idea how i could calculate the curvature for each point in the curve and then compare them? Thanks in advance.

$\endgroup$
2
  • 1
    $\begingroup$ I think your problem boils down to being able to have a common factor between the two curves. Spline factor and spline length wouldn't be related between the two curves (inner curve factor goes quicker than outter). How did you get the two curves ? Would it be ok for your application to generate the curves in GN with one central curve (midpoint between the curves) ? If yes, I have a simple solution. $\endgroup$
    – Lutzi
    Commented Apr 2 at 21:00
  • $\begingroup$ yes that would be okay, actually that would be the preferred way. In my second image you can see how i'm generating the two curves atm. I use an input bezier curve and offset its values and normals to offset it. The resample node gives a better curve with better normals for the offset. Could it be possible to store an own "Index+Angle/Curvature" and go from there? $\endgroup$
    – Chris
    Commented Apr 2 at 21:21

1 Answer 1

5
$\begingroup$

Curvature of a Curve

This solution should work for curves with variable z-position, as long as the general shape is somewhat planar.

By using the Cross Product on the tangent of the current point and the next one, we get a perpendicular vector, pointing up when curve goes to the left, and pointing down when the curve goes to the right. We can then extract the z position and test its signature.

Cross product between current tangent and next tangent

In orange is the current tangent $\vec{t_n}$, in red is the next tangent $\vec{t_{n+1}}$ and in blue the cross product. I've drawn another example a little further along the curve, where curvature is opposite.

Let's store the boolean isRightTurn as attribute. From there it's straight forward. The outter part is only define by the left/right curve and if we are in a left/right turn.

For the right curve, we reverse the boolean with Not. For the left curve, we take the boolean as is. Here is for the right curve :

Right curve computation

If we plug the isOutter attribute, we get the expected result :

Display of attribute

Oversight

The last point of the curve will not get a correct computation of the curvature. I would suggest manually giving its correct value if it generates some issue.

Oversight on last point

Blend file

$\endgroup$
1
  • 4
    $\begingroup$ Lovely answer.. I guess to default the non-existent curvature at the end-points, you could do something like make an arbitrary extension to the curves by reflecting the adjacent points about the ends, or something like that? .. But that would be a user preference, anyway.. $\endgroup$
    – Robin Betts
    Commented Apr 3 at 8:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .