Skip to main content
added 1680 characters in body
Source Link
Patter
  • 885
  • 4
  • 11

The problem is that Sample Curve just uses an arithmetic weighted mean between the two neighboring control points of the curve. Thus if e.g. at control point AA the tilt is 0 and at the next control point BB the tilt is 2pi (360°) - which is the same angle - you will get every tilt angle from 0 to 2pi in between. That might be intended but in my case I tried to align the curve to a surface (with this method: How can I align the tilt of a GN generated curve to the nearest surface normal of a target?), which is using atan2 and therefore sometimes jumps between -pi <-> +pi (-180° <-> +180°). The result is shown on the left (on the right the version described below was used):

Method 1: Fixing interpolation of Sample Curve

Luckily nowadays Sample Curve allows to sample also other values - not just position, tangent and normal. So what I do is

Here is my fixed version of Robin's X_Curve_Deform node group (it optionally still contains the non-fixed version, in case this is really wanted): enter image description here

Update
Method 2: "Detangle Tilt"

I like the above method, but there is one drawback I see: It only works if Sample Curve is used. It won't work e.g. for Curve to Mesh. So I came up with another method to fix the tilt values assigned to curve control points directly.

The idea is to find points where the tilt value changes by more than 180° from one control point to the next and to counter that by changing it by 360° in the other direction. Of course if the tilt is changed at one point also all following points have to be changed accordingly.

Here is a node group doing that (in three variants): enter image description here

The main issue is the accumulation of tilt correction values over the curve. The three variants are doing this in different ways (and probably there are some more):

  • Using Shortest Edge Paths which has the drawback to ignore negative values, which I solved here by accumulating positive and (abs) negative values separately. This is by far the fastest method
  • Using Repeat Zone (Blender 4.x)
    • Store the correction value on the i-th point of a pre-defined number of helper points.
    • Add a helper point in each iteration. This is the slowest method in my case (not sure if that changes for curves with more control points though)

Comparison of both methods:

Results of both methods look quite similar but not exactly the same. I see significant differences where the curve makes narrow turns. Probably my interpolation in method 1 is not optimal (I have to think about that a bit more)

The problem is that Sample Curve just uses an arithmetic weighted mean between the two neighboring control points of the curve. Thus if e.g. at control point A the tilt is 0 and at the next control point B the tilt is 2pi (360°) - which is the same angle - you will get every tilt angle from 0 to 2pi in between. That might be intended but in my case I tried to align the curve to a surface (with this method: How can I align the tilt of a GN generated curve to the nearest surface normal of a target?), which is using atan2 and therefore sometimes jumps between -pi <-> +pi (-180° <-> +180°). The result is shown on the left (on the right the version described below was used):

Luckily nowadays Sample Curve allows to sample also other values - not just position, tangent and normal. So what I do is

Here is my fixed version of Robin's X_Curve_Deform node group (it optionally still contains the non-fixed version, in case this is really wanted): enter image description here

The problem is that Sample Curve just uses an arithmetic weighted mean between the two neighboring control points of the curve. Thus if e.g. at control point A the tilt is 0 and at the next control point B the tilt is 2pi (360°) - which is the same angle - you will get every tilt angle from 0 to 2pi in between. That might be intended but in my case I tried to align the curve to a surface (with this method: How can I align the tilt of a GN generated curve to the nearest surface normal of a target?), which is using atan2 and therefore sometimes jumps between -pi <-> +pi (-180° <-> +180°). The result is shown on the left (on the right the version described below was used):

Method 1: Fixing interpolation of Sample Curve

Luckily nowadays Sample Curve allows to sample also other values - not just position, tangent and normal. So what I do is

Here is my fixed version of Robin's X_Curve_Deform node group (it optionally still contains the non-fixed version, in case this is really wanted): enter image description here

Update
Method 2: "Detangle Tilt"

I like the above method, but there is one drawback I see: It only works if Sample Curve is used. It won't work e.g. for Curve to Mesh. So I came up with another method to fix the tilt values assigned to curve control points directly.

The idea is to find points where the tilt value changes by more than 180° from one control point to the next and to counter that by changing it by 360° in the other direction. Of course if the tilt is changed at one point also all following points have to be changed accordingly.

Here is a node group doing that (in three variants): enter image description here

The main issue is the accumulation of tilt correction values over the curve. The three variants are doing this in different ways (and probably there are some more):

  • Using Shortest Edge Paths which has the drawback to ignore negative values, which I solved here by accumulating positive and (abs) negative values separately. This is by far the fastest method
  • Using Repeat Zone (Blender 4.x)
    • Store the correction value on the i-th point of a pre-defined number of helper points.
    • Add a helper point in each iteration. This is the slowest method in my case (not sure if that changes for curves with more control points though)

Comparison of both methods:

Results of both methods look quite similar but not exactly the same. I see significant differences where the curve makes narrow turns. Probably my interpolation in method 1 is not optimal (I have to think about that a bit more)

Bounty Ended with 500 reputation awarded by Robin Betts
added 64 characters in body
Source Link
Patter
  • 885
  • 4
  • 11

This is not a complete answer but just describing a fix for a problem in Robin Betts' answer if different tilt angles are set to different control curves and if those tilt angles are limited to e.g. [-pi..pi] (-180°..180° - e.g. if calculated by atan2) or [0..2pi] (0°..360°).

The problem is that Sample Curve just uses an arithmetic weighted mean between the two neighboring control points of the curve. Thus if e.g. at control point A the tilt is 0 and at the next control point B the tilt is 2pi (360°) - which is the same angle - you will get every tilt angle from 0 to 2pi in between. That might be intended but in my case I tried to align the curve to a surface (with this method: enter link description hereHow can I align the tilt of a GN generated curve to the nearest surface normal of a target?), which is using atan2 and therefore sometimes jumps between -pi <-> +pi (-180° <-> +180°). The result is shown on the left (on the right the version described below was used):

enter image description here

Luckily nowadays Sample Curve allows to sample also other values - not just position, tangent and normal. So what I do is

  • sample the control point index (the value usually indicates a position between between two control points, e.g. 2.5 is in the middle between control points 2 and 3)
  • get the normal and tangent at the previous and the next control point by Sample Index
  • create a weighted sum of the two normals and the two tangents and use them instead of the ones directly sampled by Sample Curve

Here is my fixed version of Robin's X_Curve_Deform node group (it optionally still contains the non-fixed version, in case this is really wanted): enter image description here

This is not a complete answer but just describing a fix for a problem in Robin Betts' answer if different tilt angles are set to different control curves and if those tilt angles are limited to e.g. [-pi..pi] (-180°..180° - e.g. if calculated by atan2) or [0..2pi] (0°..360°).

The problem is that Sample Curve just uses an arithmetic weighted mean between the two neighboring control points of the curve. Thus if e.g. at control point A the tilt is 0 and at the next control point B the tilt is 2pi (360°) - which is the same angle - you will get every tilt angle from 0 to 2pi in between. That might be intended but in my case I tried to align the curve to a surface (with this method: enter link description here), which is using atan2 and therefore sometimes jumps between -pi <-> +pi (-180° <-> +180°). The result is shown on the left (on the right the version described below was used):

enter image description here

Luckily nowadays Sample Curve allows to sample also other values - not just position, tangent and normal. So what I do is

  • sample the control point index (the value usually indicates a position between between two control points, e.g. 2.5 is in the middle between control points 2 and 3)
  • get the normal and tangent at the previous and the next control point by Sample Index
  • create a weighted sum of the two normals and the two tangents and use them instead of the ones directly sampled by Sample Curve

Here is my fixed version of Robin's X_Curve_Deform node group (it optionally still contains the non-fixed version, in case this is really wanted): enter image description here

This is not a complete answer but just describing a fix for a problem in Robin Betts' answer if different tilt angles are set to different control curves and if those tilt angles are limited to e.g. [-pi..pi] (-180°..180° - e.g. if calculated by atan2) or [0..2pi] (0°..360°).

The problem is that Sample Curve just uses an arithmetic weighted mean between the two neighboring control points of the curve. Thus if e.g. at control point A the tilt is 0 and at the next control point B the tilt is 2pi (360°) - which is the same angle - you will get every tilt angle from 0 to 2pi in between. That might be intended but in my case I tried to align the curve to a surface (with this method: How can I align the tilt of a GN generated curve to the nearest surface normal of a target?), which is using atan2 and therefore sometimes jumps between -pi <-> +pi (-180° <-> +180°). The result is shown on the left (on the right the version described below was used):

enter image description here

Luckily nowadays Sample Curve allows to sample also other values - not just position, tangent and normal. So what I do is

  • sample the control point index (the value usually indicates a position between between two control points, e.g. 2.5 is in the middle between control points 2 and 3)
  • get the normal and tangent at the previous and the next control point by Sample Index
  • create a weighted sum of the two normals and the two tangents and use them instead of the ones directly sampled by Sample Curve

Here is my fixed version of Robin's X_Curve_Deform node group (it optionally still contains the non-fixed version, in case this is really wanted): enter image description here

Source Link
Patter
  • 885
  • 4
  • 11

This is not a complete answer but just describing a fix for a problem in Robin Betts' answer if different tilt angles are set to different control curves and if those tilt angles are limited to e.g. [-pi..pi] (-180°..180° - e.g. if calculated by atan2) or [0..2pi] (0°..360°).

The problem is that Sample Curve just uses an arithmetic weighted mean between the two neighboring control points of the curve. Thus if e.g. at control point A the tilt is 0 and at the next control point B the tilt is 2pi (360°) - which is the same angle - you will get every tilt angle from 0 to 2pi in between. That might be intended but in my case I tried to align the curve to a surface (with this method: enter link description here), which is using atan2 and therefore sometimes jumps between -pi <-> +pi (-180° <-> +180°). The result is shown on the left (on the right the version described below was used):

enter image description here

Luckily nowadays Sample Curve allows to sample also other values - not just position, tangent and normal. So what I do is

  • sample the control point index (the value usually indicates a position between between two control points, e.g. 2.5 is in the middle between control points 2 and 3)
  • get the normal and tangent at the previous and the next control point by Sample Index
  • create a weighted sum of the two normals and the two tangents and use them instead of the ones directly sampled by Sample Curve

Here is my fixed version of Robin's X_Curve_Deform node group (it optionally still contains the non-fixed version, in case this is really wanted): enter image description here