Ejemplo n.º 1
0
		/// <summary> Replaces the upper 3x3 matrix values of this matrix with the values in the matrix m1.</summary>
		/// <param name="m1">The matrix that will be the new upper 3x3
		/// </param>
		public void  setRotationScale(Matrix3d m1)
		{
			m00 = m1.m00; m01 = m1.m01; m02 = m1.m02;
			m10 = m1.m10; m11 = m1.m11; m12 = m1.m12;
			m20 = m1.m20; m21 = m1.m21; m22 = m1.m22;
		}
Ejemplo n.º 2
0
		/// <summary> Sets the value of this matrix to the sum of itself and matrix m1. </summary>
		/// <param name="m1">the other matrix
		/// </param>
		public void  add(Matrix3d m1)
		{
			this.m00 += m1.m00;
			this.m01 += m1.m01;
			this.m02 += m1.m02;
			
			this.m10 += m1.m10;
			this.m11 += m1.m11;
			this.m12 += m1.m12;
			
			this.m20 += m1.m20;
			this.m21 += m1.m21;
			this.m22 += m1.m22;
		}
Ejemplo n.º 3
0
		/// <summary> Sets the value of this matrix to the matrix difference of itself and
		/// matrix m1 (this = this - m1).
		/// </summary>
		/// <param name="m1">the other matrix
		/// </param>
		public void  sub(Matrix3d m1)
		{
			this.m00 -= m1.m00;
			this.m01 -= m1.m01;
			this.m02 -= m1.m02;
			
			this.m10 -= m1.m10;
			this.m11 -= m1.m11;
			this.m12 -= m1.m12;
			
			this.m20 -= m1.m20;
			this.m21 -= m1.m21;
			this.m22 -= m1.m22;
		}
Ejemplo n.º 4
0
		/// <summary> Returns true if the L-infinite distance between this matrix
		/// and matrix m1 is less than or equal to the epsilon parameter,
		/// otherwise returns false.  The L-infinite
		/// distance is equal to 
		/// MAX[i=0,1,2 ; j=0,1,2 ; abs(this.m(i,j) - m1.m(i,j)]
		/// </summary>
		/// <param name="m1"> the matrix to be compared to this matrix
		/// </param>
		/// <param name="epsilon"> the threshold value  
		/// </param>
		public virtual bool epsilonEquals(Matrix3d m1, double epsilon)
		{
			double diff;
			
			diff = m00 - m1.m00;
			if ((diff < 0?- diff:diff) > epsilon)
				return false;
			
			diff = m01 - m1.m01;
			if ((diff < 0?- diff:diff) > epsilon)
				return false;
			
			diff = m02 - m1.m02;
			if ((diff < 0?- diff:diff) > epsilon)
				return false;
			
			diff = m10 - m1.m10;
			if ((diff < 0?- diff:diff) > epsilon)
				return false;
			
			diff = m11 - m1.m11;
			if ((diff < 0?- diff:diff) > epsilon)
				return false;
			
			diff = m12 - m1.m12;
			if ((diff < 0?- diff:diff) > epsilon)
				return false;
			
			diff = m20 - m1.m20;
			if ((diff < 0?- diff:diff) > epsilon)
				return false;
			
			diff = m21 - m1.m21;
			if ((diff < 0?- diff:diff) > epsilon)
				return false;
			
			diff = m22 - m1.m22;
			if ((diff < 0?- diff:diff) > epsilon)
				return false;
			
			return true;
		}
Ejemplo n.º 5
0
		/// <summary>  Adds a scalar to each component of the matrix m1 and places
		/// the result into this.  Matrix m1 is not modified.
		/// </summary>
		/// <param name="scalar"> the scalar adder
		/// </param>
		/// <param name="m1"> the original matrix values
		/// </param>
		public void  add(double scalar, Matrix3d m1)
		{
			this.m00 = m1.m00 + scalar;
			this.m01 = m1.m01 + scalar;
			this.m02 = m1.m02 + scalar;
			
			this.m10 = m1.m10 + scalar;
			this.m11 = m1.m11 + scalar;
			this.m12 = m1.m12 + scalar;
			
			this.m20 = m1.m20 + scalar;
			this.m21 = m1.m21 + scalar;
			this.m22 = m1.m22 + scalar;
		}
Ejemplo n.º 6
0
		/// <summary>  Multiplies the transpose of matrix m1 times matrix m2, and
		/// places the result into this.
		/// </summary>
		/// <param name="m1"> the matrix on the left hand side of the multiplication
		/// </param>
		/// <param name="m2"> the matrix on the right hand side of the multiplication
		/// </param>
		public void  mulTransposeLeft(Matrix3d m1, Matrix3d m2)
		{
			if (this != m1 && this != m2)
			{
				this.m00 = m1.m00 * m2.m00 + m1.m10 * m2.m10 + m1.m20 * m2.m20;
				this.m01 = m1.m00 * m2.m01 + m1.m10 * m2.m11 + m1.m20 * m2.m21;
				this.m02 = m1.m00 * m2.m02 + m1.m10 * m2.m12 + m1.m20 * m2.m22;
				
				this.m10 = m1.m01 * m2.m00 + m1.m11 * m2.m10 + m1.m21 * m2.m20;
				this.m11 = m1.m01 * m2.m01 + m1.m11 * m2.m11 + m1.m21 * m2.m21;
				this.m12 = m1.m01 * m2.m02 + m1.m11 * m2.m12 + m1.m21 * m2.m22;
				
				this.m20 = m1.m02 * m2.m00 + m1.m12 * m2.m10 + m1.m22 * m2.m20;
				this.m21 = m1.m02 * m2.m01 + m1.m12 * m2.m11 + m1.m22 * m2.m21;
				this.m22 = m1.m02 * m2.m02 + m1.m12 * m2.m12 + m1.m22 * m2.m22;
			}
			else
			{
				double m00, m01, m02, m10, m11, m12, m20, m21, m22; // vars for temp result matrix 
				
				m00 = m1.m00 * m2.m00 + m1.m10 * m2.m10 + m1.m20 * m2.m20;
				m01 = m1.m00 * m2.m01 + m1.m10 * m2.m11 + m1.m20 * m2.m21;
				m02 = m1.m00 * m2.m02 + m1.m10 * m2.m12 + m1.m20 * m2.m22;
				
				m10 = m1.m01 * m2.m00 + m1.m11 * m2.m10 + m1.m21 * m2.m20;
				m11 = m1.m01 * m2.m01 + m1.m11 * m2.m11 + m1.m21 * m2.m21;
				m12 = m1.m01 * m2.m02 + m1.m11 * m2.m12 + m1.m21 * m2.m22;
				
				m20 = m1.m02 * m2.m00 + m1.m12 * m2.m10 + m1.m22 * m2.m20;
				m21 = m1.m02 * m2.m01 + m1.m12 * m2.m11 + m1.m22 * m2.m21;
				m22 = m1.m02 * m2.m02 + m1.m12 * m2.m12 + m1.m22 * m2.m22;
				
				this.m00 = m00; this.m01 = m01; this.m02 = m02;
				this.m10 = m10; this.m11 = m11; this.m12 = m12;
				this.m20 = m20; this.m21 = m21; this.m22 = m22;
			}
		}
Ejemplo n.º 7
0
		/// <summary> Perform cross product normalization of matrix m1 and place the
		/// normalized values into this.
		/// </summary>
		/// <param name="m1"> Provides the matrix values to be normalized
		/// </param>
		public void  normalizeCP(Matrix3d m1)
		{
			double mag = 1.0 / System.Math.Sqrt(m1.m00 * m1.m00 + m1.m10 * m1.m10 + m1.m20 * m1.m20);
			m00 = m1.m00 * mag;
			m10 = m1.m10 * mag;
			m20 = m1.m20 * mag;
			
			mag = 1.0 / System.Math.Sqrt(m1.m01 * m1.m01 + m1.m11 * m1.m11 + m1.m21 * m1.m21);
			m01 = m1.m01 * mag;
			m11 = m1.m11 * mag;
			m21 = m1.m21 * mag;
			
			m02 = m10 * m21 - m11 * m20;
			m12 = m01 * m20 - m00 * m21;
			m22 = m00 * m11 - m01 * m10;
		}
Ejemplo n.º 8
0
		/// <summary> Replaces the upper 3x3 matrix values of this matrix with the values in the matrix m1.</summary>
		/// <param name="m1">The matrix that will be the new upper 3x3
		/// </param>
		private void  setRotationScale(Matrix3d m1)
		{
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m00 = (float) m1.m00;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m01 = (float) m1.m01;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m02 = (float) m1.m02;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m10 = (float) m1.m10;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m11 = (float) m1.m11;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m12 = (float) m1.m12;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m20 = (float) m1.m20;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m21 = (float) m1.m21;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m22 = (float) m1.m22;
		}
Ejemplo n.º 9
0
		/// <summary> Gets the upper 3x3 values of this matrix and places them into the matrix m1.</summary>
		/// <param name="m1">The matrix that will hold the values
		/// </param>
		private void  getRotationScale(Matrix3d m1)
		{
			m1.m00 = m00; m1.m01 = m01; m1.m02 = m02;
			m1.m10 = m10; m1.m11 = m11; m1.m12 = m12;
			m1.m20 = m20; m1.m21 = m21; m1.m22 = m22;
		}
Ejemplo n.º 10
0
		/// <summary> Sets the rotational component (upper 3x3) of this matrix to the matrix
		/// values in the single precision Matrix3f argument; the other elements of
		/// this matrix are unchanged; a singular value decomposition is performed
		/// on this object's upper 3x3 matrix to factor out the scale, then this
		/// object's upper 3x3 matrix components are replaced by the passed rotation
		/// components, and then the scale is reapplied to the rotational
		/// components.
		/// </summary>
		/// <param name="m1">single precision 3x3 matrix
		/// </param>
		public void  setRotation(Matrix3d m1)
		{
			float scale = SVD(null);
			setRotationScale(m1);
			mulRotationScale(scale);
		}
Ejemplo n.º 11
0
		/// <summary> Performs SVD on this matrix and gets the scale and the pure rotation.
		/// The pure rotation is placed into rot.
		/// </summary>
		/// <param name="rot">the rotation factor.
		/// </param>
		/// <returns> scale factor
		/// </returns>
		private float SVD(Matrix3d rot)
		{
			// this is a simple svd.
			// Not complete but fast and reasonable.
			// See comment in Matrix3d.
			
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			float s = (float) System.Math.Sqrt((m00 * m00 + m10 * m10 + m20 * m20 + m01 * m01 + m11 * m11 + m21 * m21 + m02 * m02 + m12 * m12 + m22 * m22) / 3.0);
			
			// zero-div may occur.
			float t = (s == 0.0f?0.0f:1.0f / s);
			
			if (rot != null)
			{
				this.getRotationScale(rot);
				rot.mul(t);
			}
			
			return s;
		}
Ejemplo n.º 12
0
		/// <summary> Sets the value of this matrix from the rotation expressed by the
		/// rotation matrix m1, the translation t1, and the scale s. The translation
		/// is not modified by the scale.
		/// </summary>
		/// <param name="m1">The rotation component
		/// </param>
		/// <param name="t1">The translation component
		/// </param>
		/// <param name="scale">The scale component
		/// </param>
		public void  set_Renamed(Matrix3d m1, Vector3d t1, double scale)
		{
			setRotationScale(m1);
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			mulRotationScale((float) scale);
			setTranslation(t1);
			m33 = 1.0f;
		}
Ejemplo n.º 13
0
		/// <summary> Sets the rotational component (upper 3x3) of this matrix to the matrix
		/// values in the double precision Matrix3d argument; the other elements of
		/// this matrix are initialized as if this were an identity matrix
		/// (ie, affine matrix with no translational component).
		/// </summary>
		/// <param name="m1">the 3x3 matrix
		/// </param>
		public void  set_Renamed(Matrix3d m1)
		{
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m00 = (float) m1.m00;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m01 = (float) m1.m01;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m02 = (float) m1.m02;
			m03 = 0.0f;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m10 = (float) m1.m10;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m11 = (float) m1.m11;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m12 = (float) m1.m12;
			m13 = 0.0f;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m20 = (float) m1.m20;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m21 = (float) m1.m21;
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			m22 = (float) m1.m22;
			m23 = 0.0f;
			m30 = 0.0f; m31 = 0.0f; m32 = 0.0f; m33 = 1.0f;
		}
Ejemplo n.º 14
0
		/// <summary> Sets the value of this quaternion to the rotational component of
		/// the passed matrix.
		/// </summary>
		/// <param name="m1">the matrix3d
		/// </param>
		public void  set_Renamed(Matrix3d m1)
		{
			double ww = 0.25 * (m1.m00 + m1.m11 + m1.m22 + 1.0);
			
			if (ww >= 0)
			{
				if (ww >= EPS2)
				{
					this.w = System.Math.Sqrt(ww);
					ww = 0.25 / this.w;
					this.x = (m1.m21 - m1.m12) * ww;
					this.y = (m1.m02 - m1.m20) * ww;
					this.z = (m1.m10 - m1.m01) * ww;
					return ;
				}
			}
			else
			{
				this.w = 0;
				this.x = 0;
				this.y = 0;
				this.z = 1;
				return ;
			}
			
			this.w = 0;
			ww = (- 0.5) * (m1.m11 + m1.m22);
			if (ww >= 0)
			{
				if (ww >= EPS2)
				{
					this.x = System.Math.Sqrt(ww);
					ww = 0.5 / this.x;
					this.y = m1.m10 * ww;
					this.z = m1.m20 * ww;
					return ;
				}
			}
			else
			{
				this.x = 0;
				this.y = 0;
				this.z = 1;
				return ;
			}
			
			this.x = 0;
			ww = 0.5 * (1.0 - m1.m22);
			if (ww >= EPS2)
			{
				this.y = System.Math.Sqrt(ww);
				this.z = m1.m21 / (2.0 * this.y);
				return ;
			}
			
			this.y = 0;
			this.z = 1;
		}
Ejemplo n.º 15
0
		/// <summary>  Multiplies matrix m1 by matrix m2, does an SVD normalization  
		/// of the result, and places the result into this matrix
		/// this = SVDnorm(m1*m2).
		/// </summary>
		/// <param name="m1"> the matrix on the left hand side of the multiplication
		/// </param>
		/// <param name="m2"> the matrix on the right hand side of the multiplication
		/// </param>
		public void  mulNormalize(Matrix3d m1, Matrix3d m2)
		{
			
			double[] tmp = new double[9]; // scratch matrix
			double[] tmp_rot = new double[9]; // scratch matrix
			double[] tmp_scale = new double[3]; // scratch matrix
			
			tmp[0] = m1.m00 * m2.m00 + m1.m01 * m2.m10 + m1.m02 * m2.m20;
			tmp[1] = m1.m00 * m2.m01 + m1.m01 * m2.m11 + m1.m02 * m2.m21;
			tmp[2] = m1.m00 * m2.m02 + m1.m01 * m2.m12 + m1.m02 * m2.m22;
			
			tmp[3] = m1.m10 * m2.m00 + m1.m11 * m2.m10 + m1.m12 * m2.m20;
			tmp[4] = m1.m10 * m2.m01 + m1.m11 * m2.m11 + m1.m12 * m2.m21;
			tmp[5] = m1.m10 * m2.m02 + m1.m11 * m2.m12 + m1.m12 * m2.m22;
			
			tmp[6] = m1.m20 * m2.m00 + m1.m21 * m2.m10 + m1.m22 * m2.m20;
			tmp[7] = m1.m20 * m2.m01 + m1.m21 * m2.m11 + m1.m22 * m2.m21;
			tmp[8] = m1.m20 * m2.m02 + m1.m21 * m2.m12 + m1.m22 * m2.m22;
			
			compute_svd(tmp, tmp_scale, tmp_rot);
			
			this.m00 = tmp_rot[0];
			this.m01 = tmp_rot[1];
			this.m02 = tmp_rot[2];
			
			this.m10 = tmp_rot[3];
			this.m11 = tmp_rot[4];
			this.m12 = tmp_rot[5];
			
			this.m20 = tmp_rot[6];
			this.m21 = tmp_rot[7];
			this.m22 = tmp_rot[8];
		}
Ejemplo n.º 16
0
		/// <summary> Performs an SVD normalization of this matrix in order to acquire the
		/// normalized rotational component; the values are placed into the Matrix3d parameter.
		/// </summary>
		/// <param name="m1">matrix into which the rotational component is placed
		/// </param>
		public void  get_Renamed(Matrix3d m1)
		{
			SVD(m1);
		}
Ejemplo n.º 17
0
		/// <summary>  Constructs a new matrix with the same values as the
		/// Matrix3d parameter.
		/// </summary>
		/// <param name="m1"> the source matrix
		/// </param>
		public Matrix3d(Matrix3d m1)
		{
			this.m00 = m1.m00;
			this.m01 = m1.m01;
			this.m02 = m1.m02;
			
			this.m10 = m1.m10;
			this.m11 = m1.m11;
			this.m12 = m1.m12;
			
			this.m20 = m1.m20;
			this.m21 = m1.m21;
			this.m22 = m1.m22;
		}
Ejemplo n.º 18
0
		/// <summary> Sets the value of this axis-angle to the rotational component of
		/// the passed matrix.
		/// If the specified matrix has no rotational component, the value
		/// of this AxisAngle4f is set to an angle of 0 about an axis of (0,1,0).
		/// </summary>
		/// <param name="m1">the matrix3d
		/// </param>
		public void  set_Renamed(Matrix3d m1)
		{
			
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			x = (float) (m1.m21 - m1.m12);
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			y = (float) (m1.m02 - m1.m20);
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			z = (float) (m1.m10 - m1.m01);
			double mag = x * x + y * y + z * z;
			
			if (mag > EPS)
			{
				mag = System.Math.Sqrt(mag);
				double sin = 0.5 * mag;
				double cos = 0.5 * (m1.m00 + m1.m11 + m1.m22 - 1.0);
				
				//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
				angle = (float) System.Math.Atan2(sin, cos);
				
				double invMag = 1.0 / mag;
				//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
				x = (float) (x * invMag);
				//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
				y = (float) (y * invMag);
				//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
				z = (float) (z * invMag);
			}
			else
			{
				x = 0.0f;
				y = 1.0f;
				z = 0.0f;
				angle = 0.0f;
			}
		}
Ejemplo n.º 19
0
		/// <summary> Perform singular value decomposition normalization of matrix m1 and
		/// place the normalized values into this.
		/// </summary>
		/// <param name="m1"> Provides the matrix values to be normalized
		/// </param>
		public void  normalize(Matrix3d m1)
		{
			
			double[] tmp = new double[9]; // scratch matrix
			double[] tmp_rot = new double[9]; // scratch matrix
			double[] tmp_scale = new double[3]; // scratch matrix
			
			tmp[0] = m1.m00;
			tmp[1] = m1.m01;
			tmp[2] = m1.m02;
			
			tmp[3] = m1.m10;
			tmp[4] = m1.m11;
			tmp[5] = m1.m12;
			
			tmp[6] = m1.m20;
			tmp[7] = m1.m21;
			tmp[8] = m1.m22;
			
			compute_svd(tmp, tmp_scale, tmp_rot);
			
			this.m00 = tmp_rot[0];
			this.m01 = tmp_rot[1];
			this.m02 = tmp_rot[2];
			
			this.m10 = tmp_rot[3];
			this.m11 = tmp_rot[4];
			this.m12 = tmp_rot[5];
			
			this.m20 = tmp_rot[6];
			this.m21 = tmp_rot[7];
			this.m22 = tmp_rot[8];
		}
Ejemplo n.º 20
0
		/// <summary> Sets the value of this matrix to the value of the Matrix3d
		/// argument.
		/// </summary>
		/// <param name="m1">the source matrix3d
		/// </param>
		public void  set_Renamed(Matrix3d m1)
		{
			this.m00 = m1.m00;
			this.m01 = m1.m01;
			this.m02 = m1.m02;
			
			this.m10 = m1.m10;
			this.m11 = m1.m11;
			this.m12 = m1.m12;
			
			this.m20 = m1.m20;
			this.m21 = m1.m21;
			this.m22 = m1.m22;
		}
Ejemplo n.º 21
0
		/// <summary> Returns true if all of the data members of Matrix3d m1 are
		/// equal to the corresponding data members in this Matrix3d.
		/// </summary>
		/// <param name="m1"> the matrix with which the comparison is made
		/// </param>
		/// <returns>  true or false
		/// </returns>
		public bool equals(Matrix3d m1)
		{
			try
			{
				return (this.m00 == m1.m00 && this.m01 == m1.m01 && this.m02 == m1.m02 && this.m10 == m1.m10 && this.m11 == m1.m11 && this.m12 == m1.m12 && this.m20 == m1.m20 && this.m21 == m1.m21 && this.m22 == m1.m22);
			}
			catch (System.NullReferenceException e2)
			{
				return false;
			}
		}
Ejemplo n.º 22
0
		/// <summary> Sets the value of this matrix to the matrix inverse
		/// of the passed matrix m1.
		/// </summary>
		/// <param name="m1">the matrix to be inverted
		/// </param>
		public void  invert(Matrix3d m1)
		{
			invertGeneral(m1);
		}
Ejemplo n.º 23
0
		/// <summary>  Sets the value of this matrix equal to the negation of
		/// of the Matrix3d parameter.
		/// </summary>
		/// <param name="m1"> the source matrix
		/// </param>
		public void  negate(Matrix3d m1)
		{
			this.m00 = - m1.m00;
			this.m01 = - m1.m01;
			this.m02 = - m1.m02;
			
			this.m10 = - m1.m10;
			this.m11 = - m1.m11;
			this.m12 = - m1.m12;
			
			this.m20 = - m1.m20;
			this.m21 = - m1.m21;
			this.m22 = - m1.m22;
		}
Ejemplo n.º 24
0
		/// <summary> General invert routine.  Inverts m1 and places the result in "this".
		/// Note that this routine handles both the "this" version and the
		/// non-"this" version.
		/// 
		/// Also note that since this routine is slow anyway, we won't worry
		/// about allocating a little bit of garbage.
		/// </summary>
		private void  invertGeneral(Matrix3d m1)
		{
			double[] result = new double[9];
			int[] row_perm = new int[3];
			int i, r, c;
			double[] tmp = new double[9]; // scratch matrix
			
			// Use LU decomposition and backsubstitution code specifically
			// for floating-point 3x3 matrices.
			
			// Copy source matrix to t1tmp 
			tmp[0] = m1.m00;
			tmp[1] = m1.m01;
			tmp[2] = m1.m02;
			
			tmp[3] = m1.m10;
			tmp[4] = m1.m11;
			tmp[5] = m1.m12;
			
			tmp[6] = m1.m20;
			tmp[7] = m1.m21;
			tmp[8] = m1.m22;
			
			
			// Calculate LU decomposition: Is the matrix singular? 
			if (!luDecomposition(tmp, row_perm))
			{
				// Matrix has no inverse 
                throw new Exception();// SingularMatrixException(VecMathI18N.getString("Matrix3d12"));
			}
			
			// Perform back substitution on the identity matrix 
			for (i = 0; i < 9; i++)
				result[i] = 0.0;
			result[0] = 1.0; result[4] = 1.0; result[8] = 1.0;
			luBacksubstitution(tmp, row_perm, result);
			
			this.m00 = result[0];
			this.m01 = result[1];
			this.m02 = result[2];
			
			this.m10 = result[3];
			this.m11 = result[4];
			this.m12 = result[5];
			
			this.m20 = result[6];
			this.m21 = result[7];
			this.m22 = result[8];
		}
Ejemplo n.º 25
0
		/// <summary> Sets the value of this matrix to the matrix sum of matrices m1 and m2.</summary>
		/// <param name="m1">the first matrix
		/// </param>
		/// <param name="m2">the second matrix
		/// </param>
		public void  add(Matrix3d m1, Matrix3d m2)
		{
			this.m00 = m1.m00 + m2.m00;
			this.m01 = m1.m01 + m2.m01;
			this.m02 = m1.m02 + m2.m02;
			
			this.m10 = m1.m10 + m2.m10;
			this.m11 = m1.m11 + m2.m11;
			this.m12 = m1.m12 + m2.m12;
			
			this.m20 = m1.m20 + m2.m20;
			this.m21 = m1.m21 + m2.m21;
			this.m22 = m1.m22 + m2.m22;
		}
Ejemplo n.º 26
0
		/// <summary> Multiplies each element of matrix m1 by a scalar and places
		/// the result into this.  Matrix m1 is not modified.
		/// </summary>
		/// <param name="scalar"> the scalar multiplier
		/// </param>
		/// <param name="m1"> the original matrix
		/// </param>
		public void  mul(double scalar, Matrix3d m1)
		{
			this.m00 = scalar * m1.m00;
			this.m01 = scalar * m1.m01;
			this.m02 = scalar * m1.m02;
			
			this.m10 = scalar * m1.m10;
			this.m11 = scalar * m1.m11;
			this.m12 = scalar * m1.m12;
			
			this.m20 = scalar * m1.m20;
			this.m21 = scalar * m1.m21;
			this.m22 = scalar * m1.m22;
		}
Ejemplo n.º 27
0
		/// <summary> Sets the value of this matrix to the matrix difference
		/// of matrices m1 and m2.
		/// </summary>
		/// <param name="m1">the first matrix
		/// </param>
		/// <param name="m2">the second matrix
		/// </param>
		public void  sub(Matrix3d m1, Matrix3d m2)
		{
			this.m00 = m1.m00 - m2.m00;
			this.m01 = m1.m01 - m2.m01;
			this.m02 = m1.m02 - m2.m02;
			
			this.m10 = m1.m10 - m2.m10;
			this.m11 = m1.m11 - m2.m11;
			this.m12 = m1.m12 - m2.m12;
			
			this.m20 = m1.m20 - m2.m20;
			this.m21 = m1.m21 - m2.m21;
			this.m22 = m1.m22 - m2.m22;
		}
Ejemplo n.º 28
0
		/// <summary> Sets the value of this matrix to the result of multiplying itself
		/// with matrix m1.
		/// </summary>
		/// <param name="m1">the other matrix
		/// </param>
		public void  mul(Matrix3d m1)
		{
			double m00, m01, m02, m10, m11, m12, m20, m21, m22;
			
			m00 = this.m00 * m1.m00 + this.m01 * m1.m10 + this.m02 * m1.m20;
			m01 = this.m00 * m1.m01 + this.m01 * m1.m11 + this.m02 * m1.m21;
			m02 = this.m00 * m1.m02 + this.m01 * m1.m12 + this.m02 * m1.m22;
			
			m10 = this.m10 * m1.m00 + this.m11 * m1.m10 + this.m12 * m1.m20;
			m11 = this.m10 * m1.m01 + this.m11 * m1.m11 + this.m12 * m1.m21;
			m12 = this.m10 * m1.m02 + this.m11 * m1.m12 + this.m12 * m1.m22;
			
			m20 = this.m20 * m1.m00 + this.m21 * m1.m10 + this.m22 * m1.m20;
			m21 = this.m20 * m1.m01 + this.m21 * m1.m11 + this.m22 * m1.m21;
			m22 = this.m20 * m1.m02 + this.m21 * m1.m12 + this.m22 * m1.m22;
			
			this.m00 = m00; this.m01 = m01; this.m02 = m02;
			this.m10 = m10; this.m11 = m11; this.m12 = m12;
			this.m20 = m20; this.m21 = m21; this.m22 = m22;
		}
Ejemplo n.º 29
0
		/// <summary> Sets the value of this matrix to the transpose of the argument matrix.</summary>
		/// <param name="m1">the matrix to be transposed
		/// </param>
		public void  transpose(Matrix3d m1)
		{
			if (this != m1)
			{
				this.m00 = m1.m00;
				this.m01 = m1.m10;
				this.m02 = m1.m20;
				
				this.m10 = m1.m01;
				this.m11 = m1.m11;
				this.m12 = m1.m21;
				
				this.m20 = m1.m02;
				this.m21 = m1.m12;
				this.m22 = m1.m22;
			}
			else
				this.transpose();
		}
Ejemplo n.º 30
0
		/// <summary> 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.
		/// </summary>
		/// <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_Renamed(Matrix3d m1, Vector3d t1)
		{
			get_Renamed(t1);
			return SVD(m1, null);
		}