38 this.angVel0 =
default(Vector3);
39 this.angVel1 =
default(Vector3);
95 this.rot0 =
rot0.ToNormalized();
96 this.rot1 =
rot1.ToNormalized();
105 float i = ((t -
t0) / (
t1 -
t0)) - 1f;
108 float i = Mathf.Clamp01((t -
t0) / (
t1 -
t0));
114 var oneThird = 1 / 3f;
116 var w1 = Quaternion.Inverse(
rot0) *
angVel0 * dt * oneThird;
117 var w3 = Quaternion.Inverse(
rot1) *
angVel1 * dt * oneThird;
118 var w2 = Mathq.Log(Mathq.Exp(-w1)
119 * Quaternion.Inverse(
rot0)
123 var beta1 = i3 - (3 * i2) + (3 * i);
124 var beta2 = -2 * i3 + 3 * i2;
127 return rot0 * Mathq.Exp(w1 * beta1) * Mathq.Exp(w2 * beta2) * Mathq.Exp(w3 * beta3);
176 float i = Mathf.Clamp01((t -
t0) / (
t1 -
t0));
182 var oneThird = 1 / 3f;
184 var w1 = Quaternion.Inverse(
rot0) *
angVel0 * dt * oneThird;
185 var w3 = Quaternion.Inverse(
rot1) *
angVel1 * dt * oneThird;
186 var w2 = (Mathq.Exp(-w1)
187 * Quaternion.Inverse(
rot0)
189 * Mathq.Exp(-w3)).ToAngleAxisVector();
191 var beta1 = i3 - (3 * i2) + (3 * i);
192 var beta2 = -2 * i3 + 3 * i2;
196 var dotBeta1 = 3 * i2 - 5 * i + 3;
197 var dotBeta2 = -6 * i2 + 6 * i;
198 var dotBeta3 = 3 * i2;
200 var rot0_times_w1beta1 =
rot0 * Mathq.Exp(w1 * beta1);
203 rot0 * w1 * dotBeta1 +
204 rot0_times_w1beta1 * w2 * dotBeta2 +
205 rot0_times_w1beta1 * Mathq.Exp(w2 * beta2) * w3 * dotBeta3;
214 out Vector3 angularVelocity) {
215 float i = Mathf.Clamp01((t -
t0) / (
t1 -
t0));
221 var oneThird = 1 / 3f;
223 var w1 = Quaternion.Inverse(
rot0) *
angVel0 * dt * oneThird;
224 var w3 = Quaternion.Inverse(
rot1) *
angVel1 * dt * oneThird;
225 var w2 = Mathq.Log(Mathq.Exp(-w1)
226 * Quaternion.Inverse(
rot0)
230 var beta1 = i3 - (3 * i2) + (3 * i);
231 var beta2 = -2 * i3 + 3 * i2;
235 rot0 * Mathq.Exp(w1 * beta1) * Mathq.Exp(w2 * beta2) * Mathq.Exp(w3 * beta3);
238 var dotBeta1 = 3 * i2 - 5 * i + 3;
239 var dotBeta2 = -6 * i2 + 6 * i;
240 var dotBeta3 = 3 * i2;
242 var rot0_times_w1beta1 =
rot0 * Mathq.Exp(w1 * beta1);
245 rot0 * w1 * dotBeta1 +
246 rot0_times_w1beta1 * w2 * dotBeta2 +
247 rot0_times_w1beta1 * Mathq.Exp(w2 * beta2) * w3 * dotBeta3;
250 #region ISpline<Quaternion, Vector3>
265 out Vector3 deltaValuePerSec) {
276 public static class Mathq {
278 #region Exponential Quaternion Map
298 public static Quaternion Exp(Vector3 angleAxisVector) {
299 var angle = angleAxisVector.magnitude;
300 var axis = angleAxisVector / angle;
301 return Quaternion.AngleAxis(angle, axis);
312 public static Vector3 Log(Quaternion quaternion) {
313 return quaternion.ToAngleAxisVector();
Represents a spline for the rotation of a rigid body from one orientation in space to another over a ...
Vector3 DerivativeAt(float t)
HermiteQuaternionSpline(float t0, float t1, Quaternion rot0, Quaternion rot1, Vector3 angVel0, Vector3 angVel1)
Constructs a spline by specifying the rotations, angular velocities, and times of the endpoints.
void RotationAndAngVelAt(float t, out Quaternion rotation, out Vector3 angularVelocity)
Gets both the rotation and the first derivative of rotation at time t. The time is clamped within the...
HermiteQuaternionSpline(Quaternion rot0, Quaternion rot1, Vector3 angVel0, Vector3 angVel1, float duration)
Constructs a Quaternion spline by specifying the rotations (as quaternions) and angular velocities (a...
void ValueAndDerivativeAt(float t, out Quaternion value, out Vector3 deltaValuePerSec)
Vector3 AngularVelocityAt(float t)
Gets the first derivative of rotation at time t. The time is clamped within the t0 - t1 range....
Quaternion RotationAt(float t)
Gets the rotation at time t along this spline. The time is clamped within the t0 - t1 range.
HermiteQuaternionSpline(Quaternion rot0, Quaternion rot1)
Constructs a Quaternion spline by specifying the rotations at the two endpoints. The angular velocity...
HermiteQuaternionSpline(Quaternion rot0, Quaternion rot1, Vector3 angVel0, Vector3 angVel1)
Constructs a Quaternion spline by specifying the rotations (as quaternions) and angular velocities (a...
Quaternion ValueAt(float t)