Beispiel #1
0
        /// <summary>
        /// The cross product of two vectors.
        /// </summary>
        /// <param name="vector1">The first vector.</param>
        /// <param name="vector2">The second vector.</param>
        /// <returns>The cross product of both vectors.</returns>
        #region public static JVector Cross(JVector vector1, JVector vector2)
        public static FPVector Cross(FPVector vector1, FPVector vector2)
        {
            FPVector result;

            FPVector.Cross(ref vector1, ref vector2, out result);
            return(result);
        }
Beispiel #2
0
        public static FPQuaternion FromToRotation(FPVector fromVector, FPVector toVector)
        {
            FPVector     w = FPVector.Cross(fromVector, toVector);
            FPQuaternion q = new FPQuaternion(w.x, w.y, w.z, FPVector.Dot(fromVector, toVector));

            q.w += FP.Sqrt(fromVector.sqrMagnitude * toVector.sqrMagnitude);
            q.Normalize();

            return(q);
        }
        /**
         *  @brief Returns the velocity of the body at some position in world space.
         **/
        public FPVector2 GetPointVelocity(FPVector2 worldPoint)
        {
            FPVector directionPoint = (position - FPCollider.Body.FPPosition).ToFPVector();

            return(FPVector.Cross(new FPVector(0, 0, FPCollider.Body.FPAngularVelocity), directionPoint).ToFPVector2() + FPCollider.Body.FPLinearVelocity);
        }
Beispiel #4
0
        /// <summary>
        /// Calculates the cross product of two vectors.
        /// </summary>
        /// <param name="value1">The first vector.</param>
        /// <param name="value2">The second vector.</param>
        /// <returns>Returns the cross product of both.</returns>
        #region public static JVector operator %(JVector value1, JVector value2)
        public static FPVector operator %(FPVector value1, FPVector value2)
        {
            FPVector result; FPVector.Cross(ref value1, ref value2, out result);

            return(result);
        }
Beispiel #5
0
        /**
         *  @brief Returns the velocity of the body at some position in world space.
         **/
        public FPVector GetPointVelocity(FPVector worldPoint)
        {
            FPVector directionPoint = position - FPCollider.Body.FPPosition;

            return(FPVector.Cross(FPCollider.Body.FPAngularVelocity, directionPoint) + FPCollider.Body.FPLinearVelocity);
        }