140 out Vector3 angularVelocity) {
156 Vector3 pos, vel, angVel;
160 pose =
new Pose(pos, rot);
161 movement =
new Movement(vel, angVel);
164 #region ISpline<Pose, Movement>
184 #region ISpline<Vector3, Vector3>
200 out Vector3 deltaValuePerT) {
213 public static class HermitePoseSplineExtensions {
215 public static void DrawPoseSpline(
this RuntimeGizmos.RuntimeGizmoDrawer drawer,
216 HermitePoseSpline spline,
218 float poseGizmoScale = 0.02f,
219 int splineResolution = 32,
220 int drawPosePeriod = 8,
221 bool drawPoses =
true,
222 bool drawSegments =
true) {
223 if (!color.HasValue) {
224 color = LeapColor.brown.WithAlpha(0.4f);
226 drawer.color = color.Value;
228 var tWidth = spline.maxT - spline.minT;
230 Vector3? prevPos =
null;
232 float tStep = (1f / splineResolution) * tWidth;
233 for (
float t = spline.minT; t <= spline.minT + tWidth; t += tStep) {
234 var pose = spline.PoseAt(t);
236 if (counter % drawPosePeriod == 0 && drawPoses) {
237 drawer.DrawPose(pose, 0.02f);
240 if (prevPos.HasValue && drawSegments) {
241 drawer.DrawLine(prevPos.Value, pose.position);
244 prevPos = pose.position;
dXType DerivativeAt(float t)
void ValueAndDerivativeAt(float t, out XType value, out dXType deltaValuePerT)
Represents a spline for poses – positions and rotations – that travel from one position and rotation ...
Quaternion RotationAt(float t)
Gets the rotation at time t along this spline. The time is clamped within the t0 - t1 range.
Movement MovementAt(float t)
Pose PoseAt(float t)
Gets the pose at time t along this spline. The time is clamped within the t0 - t1 range.
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...
HermitePoseSpline(Pose pose0, Pose pose1, Movement move0, Movement move1)
Constructs a spline by specifying the poses and movements of the two endpoints. The time range of the...
void PositionAndVelAt(float t, out Vector3 position, out Vector3 velocity)
Gets both the position and the first derivative of position at time t. The time is clamped within the...
Vector3 AngularVelocityAt(float t)
Gets the first derivative of rotation at time t. The time is clamped within the t0 - t1 range....
Vector3 PositionAt(float t)
Gets the position at time t along this spline. The time is clamped within the t0 - t1 range.
HermitePoseSpline(Pose pose0, Pose pose1)
Constructs a spline by specifying the poses of the two endpoints. The velocity and angular velocity a...
HermitePoseSpline(Pose pose0, Pose pose1, Movement move0, Movement move1, float duration)
Constructs a spline by specifying the positions and velocities of the two endpoints....
Vector3 VelocityAt(float t)
Gets the first derivative of position at time t. The time is clamped within the t0 - t1 range.
void PoseAndMovementAt(float t, out Pose pose, out Movement movement)
Gets both the rotation and the first derivative of rotation at time t. The time is clamped within the...
HermiteQuaternionSpline qSpline
void ValueAndDerivativeAt(float t, out Pose value, out Movement deltaValuePerSec)
HermitePoseSpline(float t0, float t1, Pose pose0, Pose pose1, Movement move0, Movement move1)
Constructs a spline by specifying the positions, velocities, and times of the endpoints.
Movement DerivativeAt(float t)
Represents a spline for the rotation of a rigid body from one orientation in space to another over a ...
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...
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.
Represents a spline that travels from one point in space to another over a specified time frame....
Vector3 VelocityAt(float t)
Gets the first derivative of position at time t. The time is clamped within the t0 - t1 range (thus v...
Vector3 PositionAt(float t)
Gets the position at time t along this spline. The time is clamped to t0, but can extrapolate beyon...
void PositionAndVelAt(float t, out Vector3 position, out Vector3 velocity)
Gets both the position and the first derivative of position at time ti. The time is clamped within th...
Vector3 angularVelocity
Angular velocity expressed as an angle-axis vector with angle equal to the length of the vector in de...
Vector3 velocity
The linear velocity of this Movement.
A position and rotation. You can multiply two poses; this acts like Matrix4x4 multiplication,...