Пример #1
0
		public Transformation ()
		{
			translation = new Vector3f(0,0,0);
			scale = new Vector3f(1,1,1);
			rotation = Matrix3f.Identity();
			transformation = Matrix4f.Identity();
		}
Пример #2
0
		public Matrix4f Combine() {
			transformation = Matrix4f.Identity();

			transformation.m00 = scale.x * rotation.m00;
			transformation.m01 = scale.y * rotation.m01;
			transformation.m02 = scale.z * rotation.m02;
			
			transformation.m10 = scale.x * rotation.m10;
			transformation.m11 = scale.y * rotation.m11;
			transformation.m12 = scale.z * rotation.m12;
			
			transformation.m20 = scale.x * rotation.m20;
			transformation.m21 = scale.y * rotation.m21;
			transformation.m22 = scale.z * rotation.m22;
			
			transformation.m30 = translation.x;
			transformation.m31 = translation.y;
			transformation.m32 = translation.z;
			
			return transformation;
		}
Пример #3
0
		public bool Equals (Matrix4f b)
		{
			// If parameter is null return false:
			if ((object)b == null) {
				return false;
			}
			
			// Return true if the fields match:
			bool equal = m00 == b.m00 && m11 == b.m11 && m22 == b.m22 && m33 == b.m33 
				&& m01 == b.m01 && m02 == b.m02 && m03 == b.m03 
				&& m10 == b.m10 && m12 == b.m12 && m13 == b.m13 
				&& m20 == b.m20 && m21 == b.m21 && m23 == b.m23 
				&& m30 == b.m30 && m31 == b.m31 && m32 == b.m32;
			return equal;
		}
Пример #4
0
		public bool Equals (Matrix4f b, float epsilon)
		{
			// If parameter is null return false:
			if ((object)b == null) {
				return false;
			}
			
			bool equal = true;
			if(!(QuickMath.Abs(m00-b.m00) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m01-b.m01) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m02-b.m02) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m03-b.m03) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m10-b.m10) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m11-b.m11) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m12-b.m12) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m13-b.m13) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m20-b.m20) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m21-b.m21) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m22-b.m22) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m23-b.m23) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m30-b.m30) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m31-b.m31) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m32-b.m32) <= epsilon)) {
				equal = false;
			} else if(!(QuickMath.Abs(m33-b.m33) <= epsilon)) {
				equal = false;
			} 
			return equal;
		}
Пример #5
0
		public Matrix4f CopyFrom (ref Matrix4f matrix) 
		{
			m00 = matrix.m00;
			m01 = matrix.m01;
			m02 = matrix.m02;
			m03 = matrix.m03;
			m10 = matrix.m10;
			m11 = matrix.m11;
			m12 = matrix.m12;
			m13 = matrix.m13;
			m20 = matrix.m20;
			m21 = matrix.m21;
			m22 = matrix.m22;
			m23 = matrix.m23;
			m30 = matrix.m30;
			m31 = matrix.m31;
			m32 = matrix.m32;
			m33 = matrix.m33;
			return matrix;
		}
Пример #6
0
		public Matrix4f Multiply (ref Matrix4f b, ref Matrix4f c)
		{
			c.m00 = m00 * b.m00 + m01 * b.m10 + m02 * b.m20 + m03 * b.m30;
			c.m01 = m00 * b.m01 + m01 * b.m11 + m02 * b.m21 + m03 * b.m31;
			c.m02 = m00 * b.m02 + m01 * b.m12 + m02 * b.m22 + m03 * b.m32;
			c.m03 = m00 * b.m03 + m01 * b.m13 + m02 * b.m23 + m03 * b.m33;
			
			c.m10 = m10 * b.m00 + m11 * b.m10 + m12 * b.m20 + m13 * b.m30;
			c.m11 = m10 * b.m01 + m11 * b.m11 + m12 * b.m21 + m13 * b.m31;
			c.m12 = m10 * b.m02 + m11 * b.m12 + m12 * b.m22 + m13 * b.m32;
			c.m13 = m10 * b.m03 + m11 * b.m13 + m12 * b.m23 + m13 * b.m33;
			
			c.m20 = m20 * b.m00 + m21 * b.m10 + m22 * b.m20 + m23 * b.m30;
			c.m21 = m20 * b.m01 + m21 * b.m11 + m22 * b.m21 + m23 * b.m31;
			c.m22 = m20 * b.m02 + m21 * b.m12 + m22 * b.m22 + m23 * b.m32;
			c.m23 = m20 * b.m03 + m21 * b.m13 + m22 * b.m23 + m23 * b.m33;
			
			c.m30 = m30 * b.m00 + m31 * b.m10 + m32 * b.m20 + m33 * b.m30;
			c.m31 = m30 * b.m01 + m31 * b.m11 + m32 * b.m21 + m33 * b.m31;
			c.m32 = m30 * b.m02 + m31 * b.m12 + m32 * b.m22 + m33 * b.m32;
			c.m33 = m30 * b.m03 + m31 * b.m13 + m32 * b.m23 + m33 * b.m33;
			return c;
		}
Пример #7
0
		public Matrix4f Multiply (ref Matrix4f b)
		{
			float c00 = m00 * b.m00 + m01 * b.m10 + m02 * b.m20 + m03 * b.m30;
			float c01 = m00 * b.m01 + m01 * b.m11 + m02 * b.m21 + m03 * b.m31;
			float c02 = m00 * b.m02 + m01 * b.m12 + m02 * b.m22 + m03 * b.m32;
			float c03 = m00 * b.m03 + m01 * b.m13 + m02 * b.m23 + m03 * b.m33;
			
			float c10 = m10 * b.m00 + m11 * b.m10 + m12 * b.m20 + m13 * b.m30;
			float c11 = m10 * b.m01 + m11 * b.m11 + m12 * b.m21 + m13 * b.m31;
			float c12 = m10 * b.m02 + m11 * b.m12 + m12 * b.m22 + m13 * b.m32;
			float c13 = m10 * b.m03 + m11 * b.m13 + m12 * b.m23 + m13 * b.m33;
			
			float c20 = m20 * b.m00 + m21 * b.m10 + m22 * b.m20 + m23 * b.m30;
			float c21 = m20 * b.m01 + m21 * b.m11 + m22 * b.m21 + m23 * b.m31;
			float c22 = m20 * b.m02 + m21 * b.m12 + m22 * b.m22 + m23 * b.m32;
			float c23 = m20 * b.m03 + m21 * b.m13 + m22 * b.m23 + m23 * b.m33;
			
			float c30 = m30 * b.m00 + m31 * b.m10 + m32 * b.m20 + m33 * b.m30;
			float c31 = m30 * b.m01 + m31 * b.m11 + m32 * b.m21 + m33 * b.m31;
			float c32 = m30 * b.m02 + m31 * b.m12 + m32 * b.m22 + m33 * b.m32;
			float c33 = m30 * b.m03 + m31 * b.m13 + m32 * b.m23 + m33 * b.m33;
			
			m00 = c00;
			m01 = c01;
			m02 = c02;
			m03 = c03;
			m10 = c10;
			m11 = c11;
			m12 = c12;
			m13 = c13;
			m20 = c20;
			m21 = c21;
			m22 = c22;
			m23 = c23;
			m30 = c30;
			m31 = c31;
			m32 = c32;
			m33 = c33;
			
			return this;
		}
Пример #8
0
		public Matrix4f Subtract (Matrix4f b)
		{
			m00 -= b.m00;
			m01 -= b.m01;
			m02 -= b.m02;
			m03 -= b.m03;
			m10 -= b.m10;
			m11 -= b.m11;
			m12 -= b.m12;
			m13 -= b.m13;
			m20 -= b.m20;
			m21 -= b.m21;
			m22 -= b.m22;
			m23 -= b.m23;
			m30 -= b.m30;
			m31 -= b.m31;
			m32 -= b.m32;
			m33 -= b.m33;
			return this;
		}
Пример #9
0
		public Matrix4f Add (Matrix4f b)
		{
			m00 += b.m00;
			m01 += b.m01;
			m02 += b.m02;
			m03 += b.m03;
			m10 += b.m10;
			m11 += b.m11;
			m12 += b.m12;
			m13 += b.m13;
			m20 += b.m20;
			m21 += b.m21;
			m22 += b.m22;
			m23 += b.m23;
			m30 += b.m30;
			m31 += b.m31;
			m32 += b.m32;
			m33 += b.m33;
			return this;
		}