示例#1
0
 /// <summary>Constructs and initializes a Vector3f from the specified Vector3d.</summary>
 /// <remarks>Constructs and initializes a Vector3f from the specified Vector3d.</remarks>
 /// <param name="v1">the Vector3d containing the initialization x y z data</param>
 public Vector3f(Vector3d v1)
     : base(v1)
 {
 }
示例#2
0
 /// <summary>
 /// Constructs and initializes an AxisAngle4d from the specified
 /// axis and angle.
 /// </summary>
 /// <remarks>
 /// Constructs and initializes an AxisAngle4d from the specified
 /// axis and angle.
 /// </remarks>
 /// <param name="axis">the axis</param>
 /// <param name="angle">the angle of rotation in radian</param>
 /// <since>vecmath 1.2</since>
 public AxisAngle4d(Vector3d axis, double angle)
 {
     this.x = axis.x;
     this.y = axis.y;
     this.z = axis.z;
     this.angle = angle;
 }
示例#3
0
 /// <summary>Returns the dot product of this vector and vector v1.</summary>
 /// <remarks>Returns the dot product of this vector and vector v1.</remarks>
 /// <param name="v1">the other vector</param>
 /// <returns>the dot product of this and v1</returns>
 public double Dot(Vector3d v1)
 {
     return (this.x * v1.x + this.y * v1.y + this.z * v1.z);
 }
示例#4
0
 /// <summary>Sets the value of this vector to the normalization of vector v1.</summary>
 /// <remarks>Sets the value of this vector to the normalization of vector v1.</remarks>
 /// <param name="v1">the un-normalized vector</param>
 public void Normalize(Vector3d v1)
 {
     double norm;
     norm = 1.0 / Math.Sqrt(v1.x * v1.x + v1.y * v1.y + v1.z * v1.z);
     this.x = v1.x * norm;
     this.y = v1.y * norm;
     this.z = v1.z * norm;
 }
示例#5
0
 /// <summary>
 /// Sets the value of this matrix from the rotation expressed
 /// by the quaternion q1, the translation t1, and the scale s.
 /// </summary>
 /// <remarks>
 /// Sets the value of this matrix from the rotation expressed
 /// by the quaternion q1, the translation t1, and the scale s.
 /// </remarks>
 /// <param name="q1">the rotation expressed as a quaternion</param>
 /// <param name="t1">the translation</param>
 /// <param name="s">the scale value</param>
 public void Set(Quat4d q1, Vector3d t1, double s)
 {
     this.m00 = (float)(s * (1.0 - 2.0 * q1.y * q1.y - 2.0 * q1.z * q1.z));
     this.m10 = (float)(s * (2.0 * (q1.x * q1.y + q1.w * q1.z)));
     this.m20 = (float)(s * (2.0 * (q1.x * q1.z - q1.w * q1.y)));
     this.m01 = (float)(s * (2.0 * (q1.x * q1.y - q1.w * q1.z)));
     this.m11 = (float)(s * (1.0 - 2.0 * q1.x * q1.x - 2.0 * q1.z * q1.z));
     this.m21 = (float)(s * (2.0 * (q1.y * q1.z + q1.w * q1.x)));
     this.m02 = (float)(s * (2.0 * (q1.x * q1.z + q1.w * q1.y)));
     this.m12 = (float)(s * (2.0 * (q1.y * q1.z - q1.w * q1.x)));
     this.m22 = (float)(s * (1.0 - 2.0 * q1.x * q1.x - 2.0 * q1.y * q1.y));
     this.m03 = (float)t1.x;
     this.m13 = (float)t1.y;
     this.m23 = (float)t1.z;
     this.m30 = (float)0.0;
     this.m31 = (float)0.0;
     this.m32 = (float)0.0;
     this.m33 = (float)1.0;
 }
示例#6
0
 /// <summary>
 /// Sets the value of this matrix from the rotation expressed
 /// by the quaternion q1, the translation t1, and the scale s.
 /// </summary>
 /// <remarks>
 /// Sets the value of this matrix from the rotation expressed
 /// by the quaternion q1, the translation t1, and the scale s.
 /// </remarks>
 /// <param name="q1">the rotation expressed as a quaternion</param>
 /// <param name="t1">the translation</param>
 /// <param name="s">the scale value</param>
 public void Set(Quat4f q1, Vector3d t1, double s)
 {
     this.m00 = s * (1.0 - 2.0 * q1.y * q1.y - 2.0 * q1.z * q1.z);
     this.m10 = s * (2.0 * (q1.x * q1.y + q1.w * q1.z));
     this.m20 = s * (2.0 * (q1.x * q1.z - q1.w * q1.y));
     this.m01 = s * (2.0 * (q1.x * q1.y - q1.w * q1.z));
     this.m11 = s * (1.0 - 2.0 * q1.x * q1.x - 2.0 * q1.z * q1.z);
     this.m21 = s * (2.0 * (q1.y * q1.z + q1.w * q1.x));
     this.m02 = s * (2.0 * (q1.x * q1.z + q1.w * q1.y));
     this.m12 = s * (2.0 * (q1.y * q1.z - q1.w * q1.x));
     this.m22 = s * (1.0 - 2.0 * q1.x * q1.x - 2.0 * q1.y * q1.y);
     this.m03 = t1.x;
     this.m13 = t1.y;
     this.m23 = t1.z;
     this.m30 = 0.0;
     this.m31 = 0.0;
     this.m32 = 0.0;
     this.m33 = 1.0;
 }
示例#7
0
 /// <summary>
 /// Performs an SVD normalization of this matrix to calculate
 /// the rotation as a 3x3 matrix, the translation, and the scale.
 /// </summary>
 /// <remarks>
 /// Performs an SVD normalization of this matrix to calculate
 /// the rotation as a 3x3 matrix, the translation, and the scale.
 /// None of the matrix values are modified.
 /// </remarks>
 /// <param name="m1">the normalized matrix representing the rotation</param>
 /// <param name="t1">the translation component</param>
 /// <returns>the scale component of this transform</returns>
 public double Get(Matrix3f m1, Vector3d t1)
 {
     double[] tmp_rot = new double[9];
     // scratch matrix
     double[] tmp_scale = new double[3];
     // scratch matrix
     GetScaleRotate(tmp_scale, tmp_rot);
     m1.m00 = (float)tmp_rot[0];
     m1.m01 = (float)tmp_rot[1];
     m1.m02 = (float)tmp_rot[2];
     m1.m10 = (float)tmp_rot[3];
     m1.m11 = (float)tmp_rot[4];
     m1.m12 = (float)tmp_rot[5];
     m1.m20 = (float)tmp_rot[6];
     m1.m21 = (float)tmp_rot[7];
     m1.m22 = (float)tmp_rot[8];
     t1.x = m03;
     t1.y = m13;
     t1.z = m23;
     return (Matrix3d.Max3(tmp_scale));
 }
示例#8
0
 /// <summary>
 /// Copies the matrix values in the specified column into the vector
 /// parameter.
 /// </summary>
 /// <remarks>
 /// Copies the matrix values in the specified column into the vector
 /// parameter.
 /// </remarks>
 /// <param name="column">the matrix column</param>
 /// <param name="v">the vector into which the matrix row values will be copied</param>
 public void GetColumn(int column, Vector3d v)
 {
     if (column == 0)
     {
         v.x = m00;
         v.y = m10;
         v.z = m20;
     }
     else
     {
         if (column == 1)
         {
             v.x = m01;
             v.y = m11;
             v.z = m21;
         }
         else
         {
             if (column == 2)
             {
                 v.x = m02;
                 v.y = m12;
                 v.z = m22;
             }
             else
             {
                 throw new IndexOutOfRangeException("Matrix3d getColumn");
             }
         }
     }
 }
示例#9
0
 /// <summary>
 /// Modifies the translational components of this matrix to the values
 /// of the Vector3d argument; the other values of this matrix are not
 /// modified.
 /// </summary>
 /// <remarks>
 /// Modifies the translational components of this matrix to the values
 /// of the Vector3d argument; the other values of this matrix are not
 /// modified.
 /// </remarks>
 /// <param name="trans">the translational component</param>
 public void SetTranslation(Vector3d trans)
 {
     m03 = trans.x;
     m13 = trans.y;
     m23 = trans.z;
 }
示例#10
0
 /// <summary>
 /// Transforms the normal parameter by this transform and places the value
 /// back into normal.
 /// </summary>
 /// <remarks>
 /// Transforms the normal parameter by this transform and places the value
 /// back into normal.  The fourth element of the normal is assumed to be zero.
 /// </remarks>
 /// <param name="normal">the input normal to be transformed.</param>
 public void Transform(Vector3d normal)
 {
     double x;
     double y;
     x = m00 * normal.x + m01 * normal.y + m02 * normal.z;
     y = m10 * normal.x + m11 * normal.y + m12 * normal.z;
     normal.z = m20 * normal.x + m21 * normal.y + m22 * normal.z;
     normal.x = x;
     normal.y = y;
 }
示例#11
0
 /// <summary>
 /// Constructs and initializes a Matrix4f from the rotation matrix,
 /// translation, and scale values; the scale is applied only to the
 /// rotational components of the matrix (upper 3x3) and not to the
 /// translational components of the matrix.
 /// </summary>
 /// <remarks>
 /// Constructs and initializes a Matrix4f from the rotation matrix,
 /// translation, and scale values; the scale is applied only to the
 /// rotational components of the matrix (upper 3x3) and not to the
 /// translational components of the matrix.
 /// </remarks>
 /// <param name="m1">the rotation matrix representing the rotational components</param>
 /// <param name="t1">the translational components of the matrix</param>
 /// <param name="s">the scale value applied to the rotational components</param>
 public Matrix4d(Matrix3d m1, Vector3d t1, double s)
 {
     this.m00 = m1.m00 * s;
     this.m01 = m1.m01 * s;
     this.m02 = m1.m02 * s;
     this.m03 = t1.x;
     this.m10 = m1.m10 * s;
     this.m11 = m1.m11 * s;
     this.m12 = m1.m12 * s;
     this.m13 = t1.y;
     this.m20 = m1.m20 * s;
     this.m21 = m1.m21 * s;
     this.m22 = m1.m22 * s;
     this.m23 = t1.z;
     this.m30 = 0.0;
     this.m31 = 0.0;
     this.m32 = 0.0;
     this.m33 = 1.0;
 }
示例#12
0
 /// <summary>
 /// Sets the value of this transform to a scale and translation matrix;
 /// the translation is scaled by the scale factor and all of the matrix
 /// values are modified.
 /// </summary>
 /// <remarks>
 /// Sets the value of this transform to a scale and translation matrix;
 /// the translation is scaled by the scale factor and all of the matrix
 /// values are modified.
 /// </remarks>
 /// <param name="v1">the translation amount</param>
 /// <param name="scale">the scale factor for the matrix</param>
 public void Set(Vector3d v1, double scale)
 {
     this.m00 = scale;
     this.m01 = 0.0;
     this.m02 = 0.0;
     this.m03 = scale * v1.x;
     this.m10 = 0.0;
     this.m11 = scale;
     this.m12 = 0.0;
     this.m13 = scale * v1.y;
     this.m20 = 0.0;
     this.m21 = 0.0;
     this.m22 = scale;
     this.m23 = scale * v1.z;
     this.m30 = 0.0;
     this.m31 = 0.0;
     this.m32 = 0.0;
     this.m33 = 1.0;
 }
示例#13
0
 /// <summary>
 /// Sets the value of this matrix to a translate matrix by the
 /// passed translation value.
 /// </summary>
 /// <remarks>
 /// Sets the value of this matrix to a translate matrix by the
 /// passed translation value.
 /// </remarks>
 /// <param name="v1">the translation amount</param>
 public void Set(Vector3d v1)
 {
     this.m00 = 1.0;
     this.m01 = 0.0;
     this.m02 = 0.0;
     this.m03 = v1.x;
     this.m10 = 0.0;
     this.m11 = 1.0;
     this.m12 = 0.0;
     this.m13 = v1.y;
     this.m20 = 0.0;
     this.m21 = 0.0;
     this.m22 = 1.0;
     this.m23 = v1.z;
     this.m30 = 0.0;
     this.m31 = 0.0;
     this.m32 = 0.0;
     this.m33 = 1.0;
 }
示例#14
0
 /// <summary>
 /// Sets the value of this AxisAngle4d to the specified
 /// axis and angle.
 /// </summary>
 /// <remarks>
 /// Sets the value of this AxisAngle4d to the specified
 /// axis and angle.
 /// </remarks>
 /// <param name="axis">the axis</param>
 /// <param name="angle">the angle of rotation in radians</param>
 /// <since>vecmath 1.2</since>
 public void Set(Vector3d axis, double angle)
 {
     this.x = axis.x;
     this.y = axis.y;
     this.z = axis.z;
     this.angle = angle;
 }
示例#15
0
 /// <summary>Retrieves the translational components of this matrix.</summary>
 /// <remarks>Retrieves the translational components of this matrix.</remarks>
 /// <param name="trans">the vector that will receive the translational component</param>
 public void Get(Vector3d trans)
 {
     trans.x = m03;
     trans.y = m13;
     trans.z = m23;
 }
示例#16
0
        /// <summary>Sets the specified row of this matrix3d to the Vector provided.</summary>
        /// <remarks>Sets the specified row of this matrix3d to the Vector provided.</remarks>
        /// <param name="row">the row number to be modified (zero indexed)</param>
        /// <param name="v">the replacement row</param>
        public void SetRow(int row, Vector3d v)
        {
            switch (row)
            {
                case 0:
                {
                    this.m00 = v.x;
                    this.m01 = v.y;
                    this.m02 = v.z;
                    break;
                }

                case 1:
                {
                    this.m10 = v.x;
                    this.m11 = v.y;
                    this.m12 = v.z;
                    break;
                }

                case 2:
                {
                    this.m20 = v.x;
                    this.m21 = v.y;
                    this.m22 = v.z;
                    break;
                }

                default:
                {
                    throw new IndexOutOfRangeException("Matrix3d setRow");
                }
            }
        }
示例#17
0
 /// <summary>
 /// Returns the angle in radians between this vector and the vector
 /// parameter; the return value is constrained to the range [0,PI].
 /// </summary>
 /// <remarks>
 /// Returns the angle in radians between this vector and the vector
 /// parameter; the return value is constrained to the range [0,PI].
 /// </remarks>
 /// <param name="v1">the other vector</param>
 /// <returns>the angle in radians in the range [0,PI]</returns>
 public double Angle(Vector3d v1)
 {
     double vDot = this.Dot(v1) / (this.Length() * v1.Length());
     if (vDot < -1.0)
     {
         vDot = -1.0;
     }
     if (vDot > 1.0)
     {
         vDot = 1.0;
     }
     return ((double)(Math.Acos(vDot)));
 }
示例#18
0
 /// <summary>Copies the matrix values in the specified row into the vector parameter.
 /// 	</summary>
 /// <remarks>Copies the matrix values in the specified row into the vector parameter.
 /// 	</remarks>
 /// <param name="row">the matrix row</param>
 /// <param name="v">the vector into which the matrix row values will be copied</param>
 public void GetRow(int row, Vector3d v)
 {
     if (row == 0)
     {
         v.x = m00;
         v.y = m01;
         v.z = m02;
     }
     else
     {
         if (row == 1)
         {
             v.x = m10;
             v.y = m11;
             v.z = m12;
         }
         else
         {
             if (row == 2)
             {
                 v.x = m20;
                 v.y = m21;
                 v.z = m22;
             }
             else
             {
                 throw new IndexOutOfRangeException("Matrix3d getRow");
             }
         }
     }
 }
示例#19
0
 // Combatible with 1.1
 /// <summary>Sets this vector to the vector cross product of vectors v1 and v2.</summary>
 /// <remarks>Sets this vector to the vector cross product of vectors v1 and v2.</remarks>
 /// <param name="v1">the first vector</param>
 /// <param name="v2">the second vector</param>
 public void Cross(Vector3d v1, Vector3d v2)
 {
     double x;
     double y;
     x = v1.y * v2.z - v1.z * v2.y;
     y = v2.x * v1.z - v2.z * v1.x;
     this.z = v1.x * v2.y - v1.y * v2.x;
     this.x = x;
     this.y = y;
 }
示例#20
0
 /// <summary>
 /// Sets the value of this matrix from the rotation expressed by
 /// the rotation matrix m1, the translation t1, and the scale factor.
 /// </summary>
 /// <remarks>
 /// Sets the value of this matrix from the rotation expressed by
 /// the rotation matrix m1, the translation t1, and the scale factor.
 /// The translation is not modified by the scale.
 /// </remarks>
 /// <param name="m1">the rotation component</param>
 /// <param name="t1">the translation component</param>
 /// <param name="scale">the scale factor</param>
 public void Set(Matrix3d m1, Vector3d t1, double scale)
 {
     this.m00 = (float)(m1.m00 * scale);
     this.m01 = (float)(m1.m01 * scale);
     this.m02 = (float)(m1.m02 * scale);
     this.m03 = (float)t1.x;
     this.m10 = (float)(m1.m10 * scale);
     this.m11 = (float)(m1.m11 * scale);
     this.m12 = (float)(m1.m12 * scale);
     this.m13 = (float)t1.y;
     this.m20 = (float)(m1.m20 * scale);
     this.m21 = (float)(m1.m21 * scale);
     this.m22 = (float)(m1.m22 * scale);
     this.m23 = (float)t1.z;
     this.m30 = 0.0f;
     this.m31 = 0.0f;
     this.m32 = 0.0f;
     this.m33 = 1.0f;
 }
示例#21
0
 /// <summary>
 /// Constructs and initializes a Matrix4d from the quaternion,
 /// translation, and scale values; the scale is applied only to the
 /// rotational components of the matrix (upper 3x3) and not to the
 /// translational components.
 /// </summary>
 /// <remarks>
 /// Constructs and initializes a Matrix4d from the quaternion,
 /// translation, and scale values; the scale is applied only to the
 /// rotational components of the matrix (upper 3x3) and not to the
 /// translational components.
 /// </remarks>
 /// <param name="q1">the quaternion value representing the rotational component</param>
 /// <param name="t1">the translational component of the matrix</param>
 /// <param name="s">the scale value applied to the rotational components</param>
 public Matrix4d(Quat4f q1, Vector3d t1, double s)
 {
     m00 = s * (1.0 - 2.0 * q1.y * q1.y - 2.0 * q1.z * q1.z);
     m10 = s * (2.0 * (q1.x * q1.y + q1.w * q1.z));
     m20 = s * (2.0 * (q1.x * q1.z - q1.w * q1.y));
     m01 = s * (2.0 * (q1.x * q1.y - q1.w * q1.z));
     m11 = s * (1.0 - 2.0 * q1.x * q1.x - 2.0 * q1.z * q1.z);
     m21 = s * (2.0 * (q1.y * q1.z + q1.w * q1.x));
     m02 = s * (2.0 * (q1.x * q1.z + q1.w * q1.y));
     m12 = s * (2.0 * (q1.y * q1.z - q1.w * q1.x));
     m22 = s * (1.0 - 2.0 * q1.x * q1.x - 2.0 * q1.y * q1.y);
     m03 = t1.x;
     m13 = t1.y;
     m23 = t1.z;
     m30 = 0.0;
     m31 = 0.0;
     m32 = 0.0;
     m33 = 1.0;
 }