- Home /
Question by
aqeel25 · Feb 05, 2020 at 06:48 AM ·
c#interpolationmachine
CNC circular interpolation and linear interpolation
I am creating simulator for cnc milling machine using g-codes and m-codes etc.How to calculate circular interpolation and linear interpolations? I am using unity and C#.
Comment
Answer by unity_ek98vnTRplGj8Q · Feb 05, 2020 at 03:55 PM
Mathf.Lerp -> Linear interpolation for a single float. Example: Mathf.Lerp(currentValue, targetValue, lerpAmount);
Mathf.Slerp -> Same, except will give you spherical interpolation.
For vectors (positions and directions), use Vector3.Lerp and Vector3.Slerp, and for rotations use Quaternion.Lerp and Quaternion.Slerp