예제 #1
0
 /// <summary>
 /// Matrix vector multiplication
 /// </summary>
 /// <returns></returns>
 public static Vec4d operator *(Matrix4d matrix, Vec4d vector)
 {
     return new Vec4d(
         Vec4d.Dot(vector, matrix.Row0),
         Vec4d.Dot(vector, matrix.Row1),
         Vec4d.Dot(vector, matrix.Row2),
         Vec4d.Dot(vector, matrix.Row3)
         );
 }
예제 #2
0
 /// <summary>
 /// Matrix vector multiplication
 /// </summary>
 /// <returns></returns>
 public static Vec4d Multiply(ref Matrix4d matrix, Vec4d vector)
 {
     return(new Vec4d(
                Vec4d.Dot(vector, matrix.Row0),
                Vec4d.Dot(vector, matrix.Row1),
                Vec4d.Dot(vector, matrix.Row2),
                Vec4d.Dot(vector, matrix.Row3)
                ));
 }
예제 #3
0
 /// <summary>
 /// Applies this transformation to the given vector.
 /// </summary>
 /// <param name="vector"></param>
 /// <returns></returns>
 public Vec4d Apply(Vec4d vector)
 {
     return(new Vec4d(
                Vec4d.Dot(Row0, vector),
                Vec4d.Dot(Row1, vector),
                Vec4d.Dot(Row2, vector),
                Vec4d.Dot(Row3, vector)
                ));
 }
예제 #4
0
        /// <summary>
        /// Linear interpolation between this quaternion and another.
        /// </summary>
        /// <param name="other"></param>
        /// <param name="factor"></param>
        /// <returns></returns>
        public Quaterniond LerpTo(Quaterniond other, double factor)
        {
            var ca = Vec4d.Dot(this, other);

            if (ca < 0.0)
            {
                return(new Quaterniond(
                           X + (-other.X - X) * factor,
                           Y + (-other.Y - Y) * factor,
                           Z + (-other.Z - Z) * factor,
                           W + (-other.W - W) * factor
                           ));
            }
            else
            {
                return(new Quaterniond(
                           X + (other.X - X) * factor,
                           Y + (other.Y - Y) * factor,
                           Z + (other.Z - Z) * factor,
                           W + (other.W - W) * factor
                           ));
            }
        }