How to offset a Spline?

What I’m trying to do: create a function into which I can input a spline component and an offset value and which will output a second spline component whose points have been offset by that value in the X/Y plane.

How I’m trying to do it:

  • Copy my input spline to a second spline (output spline)
  • Loop through the points on my input spline
  • Get the rotations of the spline segments before and after the current spline point using Find Look At Rotation
  • Use an RInterp node to find the middle between those two rotations
  • Get the right vector of that middle rotation, multiply it by my offset value and add it to the location vector of the current point of the input spline
  • Set the current spline point location on the output spline to the resulting vector

The issue: The segment rotation is somehow always at least slightly off. When I test the function using a spline that has only straight segments and right angles, I would expect the segment rotation values to be either 0 or multiples of 90 but they’re always off (usually somewhere in the range of 0.5-15° deviation from the expected value but there’s no discernible pattern to it that I can see). This then, of course, results in a wonky-looking output spline that does not match the course of the input spline.

Alternative solutions: I’ve previously tried using Get Tangent at Spline Point, Get Right Vector at Spline Point and Get Right Vector at Distance along Spline instead of Find Look at Rotation and had similar issues with all of them. I would think the problem was the spline itself except I created it using grid-snap and I can clearly see in the orthographic top view that it’s perfectly straight and right-angled.

Does anyone know where I’m going wrong here? I’m assuming that my entire approach to this issue may well be flawed but I’m not sure what else to do.

Hi FrozenHarlequin,

I did something like that for a retainer wall spline system - I created a function that offsets it like:

3 Likes

Hi! Thank you for the quick reply! Where exactly are you getting the rotation value from, though? I feel like that’s the main thing I’m struggling with.

I’m using the “GetTransformAtSplinePoint” for that:

2 Likes

That’s also not working for me for some reason. This is the result I get with your solution:

EDIT: The Yaw values I get off the Get Transform at Spline Point node also don’t look correct when I output them. With right angles like these, I’d expect the spline point yaw values to be sth like 90, 180, etc. but the values I get are 12.094757, -74.054604, -167.905243 and 111.801409.

What happens if you change it all to “World Space” rather than “Local Space”?

1 Like

I get slightly different values but they’re equally nonsensical. 10.125268, -75.792362, -169.874732 and 93.810499

I think it must be that you’re changing existing points to the new values- what I do is clear the entire spline (the new one) and then call AddPoint for each calculated point:

2 Likes

Oh that is weird. I would not have thought that that could affect it at all since I assign the spline to two separate variables in the beginning and use one of them for reading only and the other for assigning the new values only. But I just changed the function so it bypasses the Set Location at Spline Point node and only prints out the rotation values and now the rotation values are all correct. So clearly that must be the issue. Thanks so much :)!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.