Пример #1
0
 public Bone(string name)
 {
     m_refPosition = new Vector2D(0.0, 0.0);
     m_mat = Matrix3D.Identity.Clone();
     m_totalMat = Matrix3D.Identity.Clone();
     m_name = name;
 }
Пример #2
0
		/// <summary>
		/// Subtracts a matrix from a matrix.
		/// </summary>
		/// <param name="left">A <see cref="Matrix3D"/> instance to subtract from.</param>
		/// <param name="right">A <see cref="Matrix3D"/> instance to subtract.</param>
		/// <returns>A new <see cref="Matrix3D"/> instance containing the difference.</returns>
		/// <remarks>result[x][y] = left[x][y] - right[x][y]</remarks>
		public static Matrix3D Subtract(Matrix3D left, Matrix3D right)
		{
			return new Matrix3D(
				left.M11 - right.M11, left.M12 - right.M12, left.M13 - right.M13,
				left.M21 - right.M21, left.M22 - right.M22, left.M23 - right.M23,
				left.M31 - right.M31, left.M32 - right.M32, left.M33 - right.M33
				);
		}
Пример #3
0
		/// <summary>
		/// Adds two matrices and put the result in a third matrix.
		/// </summary>
		/// <param name="left">A <see cref="Matrix3D"/> instance.</param>
		/// <param name="right">A <see cref="Matrix3D"/> instance.</param>
		/// <param name="result">A <see cref="Matrix3D"/> instance to hold the result.</param>
		public static void Add(Matrix3D left, Matrix3D right, ref Matrix3D result)
		{
			result.M11 = left.M11 + right.M11;
			result.M12 = left.M12 + right.M12;
			result.M13 = left.M13 + right.M13;

			result.M21 = left.M21 + right.M21;
			result.M22 = left.M22 + right.M22;
			result.M23 = left.M23 + right.M23;

			result.M31 = left.M31 + right.M31;
			result.M32 = left.M32 + right.M32;
			result.M33 = left.M33 + right.M33;
		}
Пример #4
0
		/// <summary>
		/// Adds two matrices.
		/// </summary>
		/// <param name="left">A <see cref="Matrix3D"/> instance.</param>
		/// <param name="right">A <see cref="Matrix3D"/> instance.</param>
		/// <returns>A new <see cref="Matrix3D"/> instance containing the sum.</returns>
		public static Matrix3D Add(Matrix3D left, Matrix3D right)
		{
			return new Matrix3D(
				left.M11 + right.M11, left.M12 + right.M12, left.M13 + right.M13, 
				left.M21 + right.M21, left.M22 + right.M22, left.M23 + right.M23, 
				left.M31 + right.M31, left.M32 + right.M32, left.M33 + right.M33
				);
		}
Пример #5
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Matrix3D"/> class using a given matrix.
		/// </summary>
		public Matrix3D(Matrix3D m)
		{
			_m11 = m.M11; _m12 = m.M12; _m13 = m.M13;
			_m21 = m.M21; _m22 = m.M22; _m23 = m.M23;
			_m31 = m.M31; _m32 = m.M32; _m33 = m.M33;
		}
Пример #6
0
 public void SetLocalMatrix(Matrix3D mat3D)
 {
     m_mat = mat3D.Clone();
 }
Пример #7
0
 /// <summary>
 /// Adds a matrix and a scalar.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="scalar">A double-precision floating-point number.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the sum.</returns>
 public static Matrix3D operator +(double scalar, Matrix3D matrix)
 {
     return(Matrix3D.Add(matrix, scalar));
 }
Пример #8
0
		/// <summary>
		/// Transforms a given vector by a matrix.
		/// </summary>
		/// <param name="matrix">A <see cref="Matrix3D"/> instance.</param>
		/// <param name="vector">A <see cref="Vector3D"/> instance.</param>
		/// <returns>A new <see cref="Vector3D"/> instance containing the result.</returns>
		public static Vector3D Transform(Matrix3D matrix, Vector3D vector)
		{
			return new Vector3D(
				(matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z),
				(matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z),
				(matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z));
		}
Пример #9
0
 public Transform2D(Matrix3D mat)
 {
     _mat = mat.Clone();
 }
Пример #10
0
 public Transform2D(Transform2D transf)
 {
     _mat = transf._mat.Clone();
 }
Пример #11
0
 public Transform2D(Matrix3D mat)
 {
     _mat = mat.Clone();
 }
Пример #12
0
 /// <summary>
 /// Multiplies two matrices.
 /// </summary>
 /// <param name="left">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="right">A <see cref="Matrix3D"/> instance.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the result.</returns>
 public static Matrix3D operator *(Matrix3D left, Matrix3D right)
 {
     return(Matrix3D.Multiply(left, right));
 }
Пример #13
0
 /// <summary>
 /// Subtracts a scalar from a matrix.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="scalar">A double-precision floating-point number.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the difference.</returns>
 public static Matrix3D operator -(Matrix3D matrix, double scalar)
 {
     return(Matrix3D.Subtract(matrix, scalar));
 }
Пример #14
0
 /// <summary>
 /// Subtracts a matrix from a matrix.
 /// </summary>
 /// <param name="left">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="right">A <see cref="Matrix3D"/> instance.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the difference.</returns>
 public static Matrix3D operator -(Matrix3D left, Matrix3D right)
 {
     return(Matrix3D.Subtract(left, right));;
 }
Пример #15
0
		/// <summary>
		/// Subtracts a matrix from a matrix and put the result in a third matrix.
		/// </summary>
		/// <param name="left">A <see cref="Matrix3D"/> instance to subtract from.</param>
		/// <param name="right">A <see cref="Matrix3D"/> instance to subtract.</param>
		/// <param name="result">A <see cref="Matrix3D"/> instance to hold the result.</param>
		/// <remarks>result[x][y] = left[x][y] - right[x][y]</remarks>
		public static void Subtract(Matrix3D left, Matrix3D right, ref Matrix3D result)
		{
			result.M11 = left.M11 - right.M11;
			result.M12 = left.M12 - right.M12;
			result.M13 = left.M13 - right.M13;

			result.M21 = left.M21 - right.M21;
			result.M22 = left.M22 - right.M22;
			result.M23 = left.M23 - right.M23;

			result.M31 = left.M31 - right.M31;
			result.M32 = left.M32 - right.M32;
			result.M33 = left.M33 - right.M33;
		}
Пример #16
0
		/// <summary>
		/// Multiplies two matrices.
		/// </summary>
		/// <param name="left">A <see cref="Matrix3D"/> instance.</param>
		/// <param name="right">A <see cref="Matrix3D"/> instance.</param>
		/// <returns>A new <see cref="Matrix3D"/> instance containing the result.</returns>
		public static Matrix3D Multiply(Matrix3D left, Matrix3D right)
		{
			return new Matrix3D(
				left.M11 * right.M11 + left.M12 * right.M21 + left.M13 * right.M31,
				left.M11 * right.M12 + left.M12 * right.M22 + left.M13 * right.M32,
				left.M11 * right.M13 + left.M12 * right.M23 + left.M13 * right.M33,

				left.M21 * right.M11 + left.M22 * right.M21 + left.M23 * right.M31,
				left.M21 * right.M12 + left.M22 * right.M22 + left.M23 * right.M32,
				left.M21 * right.M13 + left.M22 * right.M23 + left.M23 * right.M33,

				left.M31 * right.M11 + left.M32 * right.M21 + left.M33 * right.M31,
				left.M31 * right.M12 + left.M32 * right.M22 + left.M33 * right.M32,
				left.M31 * right.M13 + left.M32 * right.M23 + left.M33 * right.M33
				);
		}
Пример #17
0
 public Transform2D(Transform2D transf)
 {
     _mat = transf._mat.Clone();
 }
Пример #18
0
		/// <summary>
		/// Transposes a matrix.
		/// </summary>
		/// <param name="m">A <see cref="Matrix3D"/> instance.</param>
		/// <returns>A new <see cref="Matrix3D"/> instance containing the transposed matrix.</returns>
		public static Matrix3D Transpose(Matrix3D m)
		{
			Matrix3D t = new Matrix3D(m);
			t.Transpose();
			return t;
		}
Пример #19
0
 public Transform2D Inverse()
 {
     return(new Transform2D(Matrix3D.Inverse(_mat)));
 }
Пример #20
0
 public void ContactLocalMatrixRight(Matrix3D mat3D)
 {
     m_mat = Matrix3D.Multiply(m_mat, mat3D);
 }
Пример #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Matrix3D"/> class using a given matrix.
 /// </summary>
 public Matrix3D(Matrix3D m)
 {
     _m11 = m.M11; _m12 = m.M12; _m13 = m.M13;
     _m21 = m.M21; _m22 = m.M22; _m23 = m.M23;
     _m31 = m.M31; _m32 = m.M32; _m33 = m.M33;
 }
Пример #22
0
        //����������ȫ�ֱ任���󴫵ݵ��ӹ����ϡ�
        public void Update(Bone parent)
        {
            if(parent == null)
            {
                m_totalMat = m_mat;
                return;
            }

            Vector2D refPosDiff = m_refPosition - parent.m_refPosition;

            //transform and then rotate
            Matrix3D transMat = Matrix.Transform2D(refPosDiff.X, refPosDiff.Y);

            m_totalMat = Matrix3D.Multiply(parent.m_totalMat, transMat);

            //contact rotate matrix
            m_totalMat = Matrix3D.Multiply(m_totalMat, m_mat);
        }
Пример #23
0
 /// <summary>
 /// Transforms a given vector by a matrix and put the result in a vector.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="vector">A <see cref="Vector3D"/> instance.</param>
 /// <param name="result">A <see cref="Vector3D"/> instance to hold the result.</param>
 public static void Transform(Matrix3D matrix, Vector3D vector, ref Vector3D result)
 {
     result.X = (matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z);
     result.Y = (matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z);
     result.Z = (matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z);
 }
Пример #24
0
		/// <summary>
		/// Converts the specified string to its <see cref="Matrix3D"/> equivalent.
		/// A return value indicates whether the conversion succeeded or failed.
		/// </summary>
		/// <param name="value">A string representation of a <see cref="Matrix3D"/>.</param>
		/// <param name="result">
		/// When this method returns, if the conversion succeeded,
		/// contains a <see cref="Matrix3D"/> representing the vector specified by <paramref name="value"/>.
		/// </param>
		/// <returns><see langword="true"/> if value was converted successfully; otherwise, <see langword="false"/>.</returns>
		/// <remarks>
		/// The string should be in the following form: "3x3..matrix elements..>".<br/>
		/// Exmaple : "3x3[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]"
		/// </remarks>
		public static bool TryParse(string value, out Matrix3D result)
		{
			Regex r = new Regex(regularExp, RegexOptions.Singleline);
			Match m = r.Match(value);
			if (m.Success)
			{
				result = new Matrix3D(
					double.Parse(m.Result("${m11}")),
					double.Parse(m.Result("${m12}")),
					double.Parse(m.Result("${m13}")),

					double.Parse(m.Result("${m21}")),
					double.Parse(m.Result("${m22}")),
					double.Parse(m.Result("${m23}")),

					double.Parse(m.Result("${m31}")),
					double.Parse(m.Result("${m32}")),
					double.Parse(m.Result("${m33}"))
					);

				return true;
			}

			result = Matrix3D.Zero;
			return false;
		}
Пример #25
0
 /// <summary>
 /// Adds two matrices.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="b">A <see cref="Matrix3D"/> instance.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the sum.</returns>
 public static Matrix3D operator+(Matrix3D a, Matrix3D b)
 {
     return(Matrix3D.Add(a, b));
 }
Пример #26
0
		/// <summary>
		/// Adds a matrix and a scalar.
		/// </summary>
		/// <param name="matrix">A <see cref="Matrix3D"/> instance.</param>
		/// <param name="scalar">A double-precision floating-point number.</param>
		/// <returns>A new <see cref="Matrix3D"/> instance containing the sum.</returns>
		public static Matrix3D Add(Matrix3D matrix, double scalar)
		{
			return new Matrix3D(
				matrix.M11 + scalar, matrix.M12 + scalar, matrix.M13 + scalar, 
				matrix.M21 + scalar, matrix.M22 + scalar, matrix.M23 + scalar, 
				matrix.M31 + scalar, matrix.M32 + scalar, matrix.M33 + scalar
				);
		}
Пример #27
0
 /// <summary>
 /// Adds a matrix and a scalar.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the sum.</returns>
 public static Matrix3D operator+(double s, Matrix3D a)
 {
     return(Matrix3D.Add(a, s));
 }
Пример #28
0
		/// <summary>
		/// Adds a matrix and a scalar and put the result in a third matrix.
		/// </summary>
		/// <param name="matrix">A <see cref="Matrix3D"/> instance.</param>
		/// <param name="scalar">A double-precision floating-point number.</param>
		/// <param name="result">A <see cref="Matrix3D"/> instance to hold the result.</param>
		public static void Add(Matrix3D matrix, double scalar, ref Matrix3D result)
		{
			result.M11 = matrix.M11 + scalar;
			result.M12 = matrix.M12 + scalar;
			result.M13 = matrix.M13 + scalar;

			result.M21 = matrix.M21 + scalar;
			result.M22 = matrix.M22 + scalar;
			result.M23 = matrix.M23 + scalar;

			result.M31 = matrix.M31 + scalar;
			result.M32 = matrix.M32 + scalar;
			result.M33 = matrix.M33 + scalar;
		}
Пример #29
0
 /// <summary>
 /// Subtracts a matrix from a matrix.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="b">A <see cref="Matrix3D"/> instance.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the difference.</returns>
 public static Matrix3D operator-(Matrix3D a, Matrix3D b)
 {
     return(Matrix3D.Subtract(a, b));
 }
Пример #30
0
		/// <summary>
		/// Subtracts a scalar from a matrix.
		/// </summary>
		/// <param name="matrix">A <see cref="Matrix3D"/> instance.</param>
		/// <param name="scalar">A double-precision floating-point number.</param>
		/// <returns>A new <see cref="Matrix3D"/> instance containing the difference.</returns>
		public static Matrix3D Subtract(Matrix3D matrix, double scalar)
		{
			return new Matrix3D(
				matrix.M11 - scalar, matrix.M12 - scalar, matrix.M13 - scalar,
				matrix.M21 - scalar, matrix.M22 - scalar, matrix.M23 - scalar,
				matrix.M31 - scalar, matrix.M32 - scalar, matrix.M33 - scalar
				);
		}
Пример #31
0
 /// <summary>
 /// Subtracts a scalar from a matrix.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the difference.</returns>
 public static Matrix3D operator-(Matrix3D a, double s)
 {
     return(Matrix3D.Subtract(a, s));
 }
Пример #32
0
		/// <summary>
		/// Subtracts a scalar from a matrix and put the result in a third matrix.
		/// </summary>
		/// <param name="matrix">A <see cref="Matrix3D"/> instance.</param>
		/// <param name="scalar">A double-precision floating-point number.</param>
		/// <param name="result">A <see cref="Matrix3D"/> instance to hold the result.</param>
		public static void Subtract(Matrix3D matrix, double scalar, ref Matrix3D result)
		{
			result.M11 = matrix.M11 - scalar;
			result.M12 = matrix.M12 - scalar;
			result.M13 = matrix.M13 - scalar;

			result.M21 = matrix.M21 - scalar;
			result.M22 = matrix.M22 - scalar;
			result.M23 = matrix.M23 - scalar;

			result.M31 = matrix.M31 - scalar;
			result.M32 = matrix.M32 - scalar;
			result.M33 = matrix.M33 - scalar;
		}
Пример #33
0
 /// <summary>
 /// Multiplies two matrices.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="b">A <see cref="Matrix3D"/> instance.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the result.</returns>
 public static Matrix3D operator*(Matrix3D a, Matrix3D b)
 {
     return(Matrix3D.Multiply(a, b));
 }
Пример #34
0
		/// <summary>
		/// Multiplies two matrices and put the result in a third matrix.
		/// </summary>
		/// <param name="left">A <see cref="Matrix3D"/> instance.</param>
		/// <param name="right">A <see cref="Matrix3D"/> instance.</param>
		/// <param name="result">A <see cref="Matrix3D"/> instance to hold the result.</param>
		public static void Multiply(Matrix3D left, Matrix3D right, ref Matrix3D result)
		{
			result.M11 = left.M11 * right.M11 + left.M12 * right.M21 + left.M13 * right.M31;
			result.M12 = left.M11 * right.M12 + left.M12 * right.M22 + left.M13 * right.M32;
			result.M13 = left.M11 * right.M13 + left.M12 * right.M23 + left.M13 * right.M33;

			result.M21 = left.M21 * right.M11 + left.M22 * right.M21 + left.M23 * right.M31;
			result.M22 = left.M21 * right.M12 + left.M22 * right.M22 + left.M23 * right.M32;
			result.M23 = left.M21 * right.M13 + left.M22 * right.M23 + left.M23 * right.M33;

			result.M31 = left.M31 * right.M11 + left.M32 * right.M21 + left.M33 * right.M31;
			result.M32 = left.M31 * right.M12 + left.M32 * right.M22 + left.M33 * right.M32;
			result.M33 = left.M31 * right.M13 + left.M32 * right.M23 + left.M33 * right.M33;
		}
Пример #35
0
 /// <summary>
 /// Transforms a given vector by a matrix.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="vector">A <see cref="Vector3D"/> instance.</param>
 /// <returns>A new <see cref="Vector3D"/> instance containing the result.</returns>
 public static Vector3D operator*(Matrix3D matrix, Vector3D vector)
 {
     return(Matrix3D.Transform(matrix, vector));
 }
Пример #36
0
		/// <summary>
		/// Transforms a given vector by a matrix and put the result in a vector.
		/// </summary>
		/// <param name="matrix">A <see cref="Matrix3D"/> instance.</param>
		/// <param name="vector">A <see cref="Vector3D"/> instance.</param>
		/// <param name="result">A <see cref="Vector3D"/> instance to hold the result.</param>
		public static void Transform(Matrix3D matrix, Vector3D vector, ref Vector3D result)
		{
			result.X = (matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z);
			result.Y = (matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z);
			result.Z = (matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z);
		}
Пример #37
0
 public void ContactLocalMatrixLeft(Matrix3D mat3D)
 {
     m_mat = Matrix3D.Multiply(mat3D, m_mat);
 }
Пример #38
0
        public static Matrix3D Inverse(Matrix3D m)
        {
            double d = 1.0/m.GetDeterminant();
            
            return new Matrix3D(
                d * (m._m33 * m._m22 - m._m32 * m._m23)
                , -d * (m._m33 * m._m12 - m._m32 * m._m13)
                , d * (m._m23 * m._m12 - m._m22 * m._m13)

                , -d * (m._m33 * m._m21 - m._m31 * m._m23)
                , d * (m._m33 * m._m11 - m._m31 * m._m13)
                , -d * (m._m23 * m._m11 - m._m21 * m._m13)

                , d * (m._m32 * m._m21 - m._m31 * m._m22)
                , -d * (m._m32 * m._m11 - m._m31 * m._m12)
                , d * (m._m22 * m._m11 - m._m21 * m._m12));
        }
Пример #39
0
 /// <summary>
 /// Adds two matrices.
 /// </summary>
 /// <param name="left">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="right">A <see cref="Matrix3D"/> instance.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the sum.</returns>
 public static Matrix3D operator +(Matrix3D left, Matrix3D right)
 {
     return(Matrix3D.Add(left, right));;
 }