Axiom.Math.Matrix4.TransformAffine C# (CSharp) Method

TransformAffine() public method

3-D Vector transformation specially for affine matrix.
Transforms the given 3-D vector by the matrix, projecting the result back into w = 1. The matrix must be an affine matrix. Matrix4.IsAffine.
public TransformAffine ( Vector3 v ) : Vector3
v Vector3
return Vector3
		public Vector3 TransformAffine( Vector3 v )
		{
			Debug.Assert( IsAffine );

			return new Vector3(
					m00 * v.x + m01 * v.y + m02 * v.z + m03,
					m10 * v.x + m11 * v.y + m12 * v.z + m13,
					m20 * v.x + m21 * v.y + m22 * v.z + m23 );
		}

Same methods

Matrix4::TransformAffine ( Vector4 v ) : Vector4

Usage Example

Example #1
0
        public void TransformAffine(Matrix4 m)
        {
            Debug.Assert(m.IsAffine);

            // Do nothing if current null or infinite
            if (this.isNull || this.isInfinite)
            {
                return;
            }

            Vector3 centre   = Center;
            Vector3 halfSize = HalfSize;

            Vector3 newCentre   = m.TransformAffine(centre);
            var     newHalfSize =
                new Vector3(
                    Utility.Abs(m[0, 0]) * halfSize.x + Utility.Abs(m[0, 1]) * halfSize.y + Utility.Abs(m[0, 2]) * halfSize.z,
                    Utility.Abs(m[1, 0]) * halfSize.x + Utility.Abs(m[1, 1]) * halfSize.y + Utility.Abs(m[1, 2]) * halfSize.z,
                    Utility.Abs(m[2, 0]) * halfSize.x + Utility.Abs(m[2, 1]) * halfSize.y + Utility.Abs(m[2, 2]) * halfSize.z);

            SetExtents(newCentre - newHalfSize, newCentre + newHalfSize);
        }
All Usage Examples Of Axiom.Math.Matrix4::TransformAffine