Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I find the point on the spline after applying with offset angle+radius?
#1
I have the point on the spline that isn't applied with offset angle and offset radius yet.
How can I find the point on the spline after applying with offset angle and offset radius?
Reply
#2
Hi
Here is the code applying the offset:

Code:
        /// <summary>
        /// Returns the position of the controller after applying an offset
        /// </summary>
        /// <param name="position">The controller's position</param>
        /// <param name="tangent">The tangent at the controller's position</param>
        /// <param name="up">The Up direction at the controller's position</param>
        /// <param name="offsetAngle"><see cref="OffsetAngle"/></param>
        /// <param name="offsetRadius"><see cref="OffsetRadius"/></param>
        protected static Vector3 ApplyOffset(Vector3 position, Vector3 tangent, Vector3 up, float offsetAngle, float offsetRadius)
        {
            Quaternion offsetRotation = Quaternion.AngleAxis(offsetAngle, tangent);
            return position.Addition((offsetRotation * up).Multiply(offsetRadius));
        }

As you can see, the point is at a radius of offsetRadius from the point on the spline, and has an angle of offsetAngle with the spline's up vector (also called orientation) at said point.
I hope this helped
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Adjust radius of generated mesh via script? Shackman 1 3 03-26-2024, 01:12 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 13 03-04-2024, 11:06 AM
Last Post: _Aka_
  Avoiding runtime GC allocations on control point position change Ell223 8 18 02-24-2024, 10:43 AM
Last Post: _Aka_

Forum Jump: