Ejemplo n.º 1
0
        ///<summary>
        /// Access the Direction of the Spline
        // relative to Spline Control Points; points that control the orientation of a Curve
        ///<summary>
        public Vector3 GetDirection(int index)
        {
            Vector3 result = (index == this.ControlPointCount - 1) ? Spline.GetDerivative(this.GetControlPointPosition(index - 3), this.GetControlPointPosition(index - 2), this.GetControlPointPosition(index - 1), this.GetControlPointPosition(index), 1f) : Spline.GetDerivative(this.GetControlPointPosition(index), this.GetControlPointPosition(index + 1), this.GetControlPointPosition(index + 2), this.GetControlPointPosition(index + 3), 0f);

            result.Normalize();
            return(result);
        }
Ejemplo n.º 2
0
        ///<summary>
        /// Access the Normals relative
        /// to the Rate of Change of the Interpolation
        ///<summary>
        public Vector3 GetNormal(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 n0, Vector3 n1, float t)
        {
            Vector3 derivative = Spline.GetDerivative(p0, p1, p2, p3, 0f);                                             // Create a Derivative based off the Spline Points
            Vector3 vector     = Quaternion.FromToRotation(Spline.GetDerivative(p0, p1, p2, p3, 1f), derivative) * n1; // Create a Rotation from the Derivative multipled by the Spline Normals

            Quaternion.FromToRotation(derivative, vector);
            Quaternion rotation = Quaternion.AngleAxis(Vector3.SignedAngle(n0, vector, derivative) * t, Spline.GetDerivative(p0, p1, p2, p3, t)); // This Rotation will Rotate around the Derivative relative to the Interpolator

            n0 = Quaternion.FromToRotation(derivative, Spline.GetDerivative(p0, p1, p2, p3, t)) * n0;                                             // This Rotation will Rotate from the Vector Derivative relative to the Spline Derivative
            return(rotation * n0);
        }