Question by
sama-van · Dec 29, 2017 at 01:16 AM ·
quaternionquaternion.lookrotation
Uniform quaternion from a list of points?
Hi!
Opened a thread here but no answer yet then.....
I have a list of points, and trying to get the correction Quaternion for each points. Unfortunately when the forward direction change, the Up direction change brutally...
Any idea how to fix this? :)
sample code from the loop defining the quaternion of each points :
Quaternion [] GetQuaternions1(Vector3 [] points)
{
List<Quaternion> rotations = new List<Quaternion> ();
Quaternion quatFrom, quatTo = new Quaternion();
for (int i = 0; i < points.Length; i++)
{
if (i == 0)
{
quatTo = Quaternion.LookRotation (points [i + 1] - points [i]);
rotations.Add(quatTo);
}
else if (points.Length > 1 && i > 0)
{
if (i < points.Length - 1)
{
quatFrom = quatTo;
quatTo = Quaternion.LookRotation (points [i + 1] - points [i]);
}
rotations.Add(quatTo);
}
}
return rotations.ToArray ();
}
Comment