Ejemplo n.º 1
0
		public void GetGLMatrix( out btMatrix3x3 m )
		{
#if !COLUMN_MAJOR_EXPECTED
			m = m_basis;
			m.m_el3 = m_origin;
			m.m_el3.w = 1;
#else
			m.m_el0.x = m_basis.m_el0.x;
			m.m_el0.y = m_basis.m_el1.x;
			m.m_el0.z = m_basis.m_el2.x;
			m.m_el0.w = m_basis.m_el0.w;

			m.m_el1.x = m_basis.m_el0.y;
			m.m_el1.y = m_basis.m_el1.y;
			m.m_el1.z = m_basis.m_el2.y;
			m.m_el1.w = m_basis.m_el1.w;

			m.m_el2.x = m_basis.m_el0.z;
			m.m_el2.y = m_basis.m_el1.z;
			m.m_el2.z = m_basis.m_el2.z;
			m.m_el2.w = m_basis.m_el2.w;
			m.m_el3 = m_origin;
			m.m_el3.w = m_basis[3][3];
#endif
		}
Ejemplo n.º 2
0
		public void adjoint( out btMatrix3x3 result )
		{
			btMatrix3x3.setValue( out result, cofac( 1, 1, 2, 2 ), cofac( 0, 2, 2, 1 ), cofac( 0, 1, 1, 2 ),
				cofac( 1, 2, 2, 0 ), cofac( 0, 0, 2, 2 ), cofac( 0, 2, 1, 0 ),
				cofac( 1, 0, 2, 1 ), cofac( 0, 1, 2, 0 ), cofac( 0, 0, 1, 1 ) );
		}
Ejemplo n.º 3
0
		public void transposeTimes( ref btMatrix3x3 m, out btMatrix3x3 result )
		{
			result.m_el0.x = m_el0.x * m.m_el0.x + m_el1.x * m.m_el1.x + m_el2.x * m.m_el2.x;
			result.m_el0.y = m_el0.x * m.m_el0.y + m_el1.x * m.m_el1.y + m_el2.x * m.m_el2.y;
			result.m_el0.z = m_el0.x * m.m_el0.z + m_el1.x * m.m_el1.z + m_el2.x * m.m_el2.z;
			result.m_el0.w = 0;
			result.m_el1.x = m_el0.y * m.m_el0.x + m_el1.y * m.m_el1.x + m_el2.y * m.m_el2.x;
			result.m_el1.y = m_el0.y * m.m_el0.y + m_el1.y * m.m_el1.y + m_el2.y * m.m_el2.y;
			result.m_el1.z = m_el0.y * m.m_el0.z + m_el1.y * m.m_el1.z + m_el2.y * m.m_el2.z;
			result.m_el1.w = 0;
			result.m_el2.x = m_el0.z * m.m_el0.x + m_el1.z * m.m_el1.x + m_el2.z * m.m_el2.x;
			result.m_el2.y = m_el0.z * m.m_el0.y + m_el1.z * m.m_el1.y + m_el2.z * m.m_el2.y;
			result.m_el2.z = m_el0.z * m.m_el0.z + m_el1.z * m.m_el1.z + m_el2.z * m.m_el2.z;
			result.m_el2.w = 0;

			result.m_el3.x = 0;
			result.m_el3.y = 0;
			result.m_el3.z = 0;
			result.m_el3.w = 1;
		}
Ejemplo n.º 4
0
		public void Add( ref btMatrix3x3 m2, out btMatrix3x3 result )
		{
			m_el0.Add( ref m2.m_el0, out result.m_el0 );
			m_el1.Add( ref m2.m_el1, out result.m_el1 );
			m_el2.Add( ref m2.m_el2, out result.m_el2 );
			m_el3.Add( ref m2.m_el3, out result.m_el3 );
		}
Ejemplo n.º 5
0
		public void absolute( out btMatrix3x3 result )
		{
			btMatrix3x3.setValue( out result,
					btScalar.btFabs( m_el0.x ), btScalar.btFabs( m_el0.y ), btScalar.btFabs( m_el0.z ),
					btScalar.btFabs( m_el1.x ), btScalar.btFabs( m_el1.y ), btScalar.btFabs( m_el1.z ),
					btScalar.btFabs( m_el2.x ), btScalar.btFabs( m_el2.y ), btScalar.btFabs( m_el2.z ) );
		}
Ejemplo n.º 6
0
		public static void Mult( ref btMatrix3x3 m, float k, out btMatrix3x3 result )
		{
			m.m_el0.Mult( k, out result.m_el0 );
			m.m_el1.Mult( k, out result.m_el1 );
			m.m_el2.Mult( k, out result.m_el2 );
			m.m_el3.Mult( k, out result.m_el3 );
		}
Ejemplo n.º 7
0
		public static void Mult( ref btMatrix3x3 m, ref btVector3 v, out btVector3 result )
		{
			result.x = m.m_el0.dot( ref v );
			result.y = m.m_el1.dot( ref v );
			result.z = m.m_el2.dot( ref v );
			result.w = m.m_el3.dot( ref v );
		}
Ejemplo n.º 8
0
		/*@brief Constructor from btQuaternion (optional btVector3 )
		  @param q Rotation from quaternion 
		  @param c Translation from Vector (default 0,0,0) */
		public void setValue( ref btQuaternion q, ref btVector3 c )
		{
			m_basis = new btMatrix3x3( ref q );
			m_origin = c;
		}
Ejemplo n.º 9
0
		/*@brief Constructor from btMatrix3x3 (optional btVector3)
		  @param b Rotation from Matrix 
		  @param c Translation from Vector default (0,0,0)*/
		public btTransform( ref btMatrix3x3 b, ref btVector3 c )
		{
			m_basis = b;
			m_origin = c;
		}
Ejemplo n.º 10
0
		/*@brief Constructor from btMatrix3x3 (optional btVector3)
		  @param b Rotation from Matrix 
		  @param c Translation from Vector default (0,0,0)*/
		public btTransform( ref btMatrix3x3 b )
		{
			m_basis = b;
			m_origin = btVector3.Zero;
		}
Ejemplo n.º 11
0
		/*@brief Constructor from btQuaternion (optional btVector3 )
		  @param q Rotation from quaternion 
		  @param c Translation from Vector (default 0,0,0) */
		public btTransform( ref btQuaternion q, ref btVector3 c )
		{
			m_basis = new btMatrix3x3( ref q );
			m_origin = c;
		}
Ejemplo n.º 12
0
		public btTransform( ref btVector3 q )
		{
			m_basis = btMatrix3x3.Identity;
			m_origin = q;
		}
Ejemplo n.º 13
0
		/*@brief Constructor from btQuaternion (optional btVector3 )
		  @param q Rotation from quaternion 
		  @param c Translation from Vector (default 0,0,0) */
		public btTransform( ref btQuaternion q )
		{
			m_basis = new btMatrix3x3( ref q );
			m_origin = btVector3.Zero;
		}
Ejemplo n.º 14
0
		public void GetGLCameraMatrix( out btMatrix3x3 m )
		{
#if !COLUMN_MAJOR_EXPECTED
			m.m_el0.x = m_basis.m_el0.x;
			m.m_el0.y = m_basis.m_el1.x;
			m.m_el0.z = -m_basis.m_el2.x;
			m.m_el0.w = 0;

			m.m_el1.x = m_basis.m_el0.y;
			m.m_el1.y = m_basis.m_el1.y;
			m.m_el1.z = -m_basis.m_el2.y;
			m.m_el1.w = 0;// m_basis.m_el1.w;

			m.m_el2.x = m_basis.m_el0.z;
			m.m_el2.y = m_basis.m_el1.z;
			m.m_el2.z = -m_basis.m_el2.z;
			m.m_el2.w = 0;// m_basis.m_el2.w;
			//m.m_el3 = 
			btVector3 negOrigin;
			m_origin.Invert( out negOrigin );
			m_basis.m_el2.Invert( out m_basis.m_el2 );
			m_basis.ApplyInverseRotation( ref negOrigin, out m.m_el3 );
			m_basis.m_el2.Invert( out m_basis.m_el2 );
			m.m_el3.w = 1;
#else
			m = m_basis;
			btVector3 tmp;
			btVector3 negOrigin;
			m_origin.Invert( out negOrigin );
			m.m_el0.z = -m.m_el0.z;
			m.m_el1.z = -m.m_el1.z;
			m.m_el2.z = -m.m_el2.z;
			m_basis.m_el0.z = -m_basis.m_el0.z;
			m_basis.m_el1.z = -m_basis.m_el1.z;
			m_basis.m_el2.z = -m_basis.m_el2.z;
			m_basis.ApplyInverseRotation( ref negOrigin, out tmp );
			m_basis.m_el0.z = -m_basis.m_el0.z;
			m_basis.m_el1.z = -m_basis.m_el1.z;
			m_basis.m_el2.z = -m_basis.m_el2.z;
			m.m_el3.x = tmp.x;
			m.m_el3.y = tmp.y;
			m.m_el3.z = tmp.z;
			m.m_el3.w = m_basis[3][3];
#endif
		}
Ejemplo n.º 15
0
		public static void setRotation( out btMatrix3x3 result, ref btQuaternion q )
		{
			float d = q.length2();
#if PARANOID_ASSERTS
			Debug.Assert( d != 0 );
#endif
			float s = btScalar.BT_TWO / d;

			float xs = q.x * s, ys = q.y * s, zs = q.z * s;
			float wx = q.w * xs, wy = q.w * ys, wz = q.w * zs;
			float xx = q.x * xs, xy = q.x * ys, xz = q.x * zs;
			float yy = q.y * ys, yz = q.y * zs, zz = q.z * zs;
			btMatrix3x3.setValue( out result,
				btScalar.BT_ONE - ( yy + zz ), xy - wz, xz + wy,
				xy + wz, btScalar.BT_ONE - ( xx + zz ), yz - wx,
				xz - wy, yz + wx, btScalar.BT_ONE - ( xx + yy ) );
		}
Ejemplo n.º 16
0
		/*@brief Constructor from btMatrix3x3 (optional btVector3)
		  @param b Rotation from Matrix 
		  @param c Translation from Vector default (0,0,0)*/
		public void setValue( ref btMatrix3x3 b, ref btVector3 c )
		{
			m_basis = b;
			m_origin = c;
		}
Ejemplo n.º 17
0
		/*@brief Create a scaled copy of the matrix 
		 @param s Scaling vector The elements of the vector will scale each column */

		public void scaled( ref btVector3 s, out btMatrix3x3 result )
		{
			btMatrix3x3.setValue( out result,
				m_el0.x * s.x, m_el0.y * s.y, m_el0.z * s.z,
				m_el1.x * s.x, m_el1.y * s.y, m_el1.z * s.z,
				m_el2.x * s.x, m_el2.y * s.y, m_el2.z * s.z );
		}
Ejemplo n.º 18
0
		/*@brief Copy constructor */
		public btTransform( ref btTransform other )
		{
			m_basis = other.m_basis;
			m_origin = other.m_origin;
		}
Ejemplo n.º 19
0
		public void Mult( float k, out btMatrix3x3 result )
		{
			m_el0.Mult( k, out result.m_el0 );
			m_el1.Mult( k, out result.m_el1 );
			m_el2.Mult( k, out result.m_el2 );
			m_el3.Mult( k, out result.m_el3 );
		}
Ejemplo n.º 20
0
		public void dot3( ref btMatrix3x3 m, out btVector3 result )
		{
			result.x = dot( ref m.m_el0 );
			result.y = dot( ref m.m_el1 );
			result.z = dot( ref m.m_el2 );
			result.w = 0;
		}
Ejemplo n.º 21
0
		public void Mult( ref btMatrix3x3 m2, out btMatrix3x3 result )
		{
			result.m_el0.x = m2.tdotx( ref m_el0 );
			result.m_el0.y = m2.tdoty( ref m_el0 );
			result.m_el0.z = m2.tdotz( ref m_el0 );
			result.m_el0.w = 0;
			result.m_el1.x = m2.tdotx( ref m_el1 );
			result.m_el1.y = m2.tdoty( ref m_el1 );
			result.m_el1.z = m2.tdotz( ref m_el1 );
			result.m_el1.w = 0;
			result.m_el2.x = m2.tdotx( ref m_el2 );
			result.m_el2.y = m2.tdoty( ref m_el2 );
			result.m_el2.z = m2.tdotz( ref m_el2 );
			result.m_el2.w = 0;
			result.m_el3.x = 0;
			result.m_el3.y = 0;
			result.m_el3.z = 0;
			result.m_el3.w = 1;
		}
Ejemplo n.º 22
0
		/*
		public btMatrix3x3 btMultTransposeLeft(btMatrix3x3 m1, btMatrix3x3 m2) {
		return btMatrix3x3(
		m1[0,0] * m2[0,0] + m1[1,0] * m2[1,0] + m1[2,0] * m2[2,0],
		m1[0,0] * m2[0,1] + m1[1,0] * m2[1,1] + m1[2,0] * m2[2,1],
		m1[0,0] * m2[0,2] + m1[1,0] * m2[1,2] + m1[2,0] * m2[2,2],
		m1[0,1] * m2[0,0] + m1[1,1] * m2[1,0] + m1[2,1] * m2[2,0],
		m1[0,1] * m2[0,1] + m1[1,1] * m2[1,1] + m1[2,1] * m2[2,1],
		m1[0,1] * m2[0,2] + m1[1,1] * m2[1,2] + m1[2,1] * m2[2,2],
		m1[0,2] * m2[0,0] + m1[1,2] * m2[1,0] + m1[2,2] * m2[2,0],
		m1[0,2] * m2[0,1] + m1[1,2] * m2[1,1] + m1[2,2] * m2[2,1],
		m1[0,2] * m2[0,2] + m1[1,2] * m2[1,2] + m1[2,2] * m2[2,2]);
		}
		*/

		/*@brief Equality operator between two matrices
		 It will test all elements are equal. * */
		public bool Equals( ref btMatrix3x3 m1 )
		{
			return ( m1.m_el0.x == m_el0.x && m1.m_el1.x == m_el1.x && m1.m_el2.x == m_el2.x &&
					m1.m_el0.y == m_el0.y && m1.m_el1.y == m_el1.y && m1.m_el2.y == m_el2.y &&
					m1.m_el0.z == m_el0.z && m1.m_el1.z == m_el1.z && m1.m_el2.z == m_el2.z );
		}
Ejemplo n.º 23
0
		public void Sub( ref btMatrix3x3 m2, out btMatrix3x3 result )
		{
			m_el0.Sub( ref m2.m_el0, out result.m_el0 );
			m_el1.Sub( ref m2.m_el1, out result.m_el1 );
			m_el2.Sub( ref m2.m_el2, out result.m_el2 );
			m_el3.Sub( ref m2.m_el3, out result.m_el3 );
		}
Ejemplo n.º 24
0
		void GetGLMatrix( out btMatrix3x3 m )
		{
			m = this;
			btVector3 tmp;
			ApplyInverseRotation( ref m_el3, out tmp );
			m.m_el3.x = tmp.x;
			m.m_el3.y = tmp.y;
			m.m_el3.z = tmp.z;
			m.m_el3.w = this[3][3];
		}
Ejemplo n.º 25
0
		public void transpose( out btMatrix3x3 result )
		{
			result.m_el0.x = m_el0.x;
			result.m_el0.y = m_el1.x;
			result.m_el0.z = m_el2.x;
			result.m_el0.w = m_el3.x;

			result.m_el1.x = m_el0.y;
			result.m_el1.y = m_el1.y;
			result.m_el1.z = m_el2.y;
			result.m_el1.w = m_el3.y;

			result.m_el2.x = m_el0.z;
			result.m_el2.y = m_el1.z;
			result.m_el2.z = m_el2.z;
			result.m_el2.w = m_el3.z;

			result.m_el3.x = m_el0.w;
			result.m_el3.y = m_el1.w;
			result.m_el3.z = m_el2.w;
			result.m_el3.w = m_el3.w;
		}
Ejemplo n.º 26
0
		// Copy constructor
		public btMatrix3x3( ref btMatrix3x3 rhs )
		{
			m_el0.x = rhs.m_el0.x; m_el0.y = rhs.m_el0.y; m_el0.z = rhs.m_el0.z; m_el0.w = rhs.m_el0.w;
			m_el1.x = rhs.m_el1.x; m_el1.y = rhs.m_el1.y; m_el1.z = rhs.m_el1.z; m_el1.w = rhs.m_el1.w;
			m_el2.x = rhs.m_el2.x; m_el2.y = rhs.m_el2.y; m_el2.z = rhs.m_el2.z; m_el2.w = rhs.m_el2.w;
			m_el3.x = rhs.m_el3.x; m_el3.y = rhs.m_el3.y; m_el3.z = rhs.m_el3.z; m_el3.w = rhs.m_el3.w;
		}
Ejemplo n.º 27
0
		/*
				public btMatrix3x3 inverse()
				{
					btVector3 co = new btVector3( cofac( 1, 1, 2, 2 ), cofac( 1, 2, 2, 0 ), cofac( 1, 0, 2, 1 ) );
					float det = m_el0.dot( ref co );
#if PARANOID_ASSERTS
					Debug.Assert( det != 0 );
#endif
					float s = 1.0 / det;
					return new btMatrix3x3( co.x * s, cofac( 0, 2, 2, 1 ) * s, cofac( 0, 1, 1, 2 ) * s,
							co.y * s, cofac( 0, 0, 2, 2 ) * s, cofac( 0, 2, 1, 0 ) * s,
							co.z * s, cofac( 0, 1, 2, 0 ) * s, cofac( 0, 0, 1, 1 ) * s );
				}
				*/
		public void inverse( out btMatrix3x3 result )
		{
			btVector3 co = new btVector3( cofac( 1, 1, 2, 2 ), cofac( 1, 2, 2, 0 ), cofac( 1, 0, 2, 1 ) );
			float det = m_el0.dot( ref co );
#if PARANOID_ASSERTS
			Debug.Assert( det != 0 );
#endif
			float s = btScalar.BT_ONE / det;
			result.m_el0.x = co.x * s;
			result.m_el0.y = cofac( 0, 2, 2, 1 ) * s;
			result.m_el0.z = cofac( 0, 1, 1, 2 ) * s;
			result.m_el0.w = 0;
			result.m_el1.x = co.y * s;
			result.m_el1.y = cofac( 0, 0, 2, 2 ) * s;
			result.m_el1.z = cofac( 0, 2, 1, 0 ) * s;
			result.m_el1.w = 0;
			result.m_el2.x = co.z * s;
			result.m_el2.y = cofac( 0, 1, 2, 0 ) * s;
			result.m_el2.z = cofac( 0, 0, 1, 1 ) * s;
			result.m_el2.w = 0;

			result.m_el3.x = 0;
			result.m_el3.y = 0;
			result.m_el3.z = 0;
			result.m_el3.w = 0;
		}
Ejemplo n.º 28
0
		public static void setValue( out btMatrix3x3 m, float xx, float xy, float xz,
			float yx, float yy, float yz,
			float zx, float zy, float zz )
		{
			m.m_el0.x = xx; m.m_el1.x = xy; m.m_el2.x = xz; m.m_el3.x = 0;
			m.m_el0.y = yx; m.m_el1.y = yy; m.m_el2.y = yz; m.m_el3.y = 0;
			m.m_el0.z = zx; m.m_el1.z = zy; m.m_el2.z = zz; m.m_el3.z = 0;
			m.m_el0.w = 0; m.m_el1.w = 0; m.m_el2.w = 0; m.m_el3.w = 1;
		}
Ejemplo n.º 29
0
		public void timesTranspose( ref btMatrix3x3 m, out btMatrix3x3 result )
		{
			result.m_el0.x = m_el0.dot( ref m.m_el0 );
			result.m_el0.y = m_el0.dot( ref m.m_el1 );
			result.m_el0.z = m_el0.dot( ref m.m_el2 );
			result.m_el0.w = 0;

			result.m_el1.x = m_el1.dot( ref m.m_el0 );
			result.m_el1.y = m_el1.dot( ref m.m_el1 );
			result.m_el1.z = m_el1.dot( ref m.m_el2 );
			result.m_el1.w = 0;

			result.m_el2.x = m_el2.dot( ref m.m_el0 );
			result.m_el2.y = m_el2.dot( ref m.m_el1 );
			result.m_el2.z = m_el2.dot( ref m.m_el2 );
			result.m_el2.w = 0;

			result.m_el3.x = 0;
			result.m_el3.y = 0;
			result.m_el3.z = 0;
			result.m_el3.w = 1;
		}
Ejemplo n.º 30
0
		/*@brief Set the rotational element by btMatrix3x3 */
		public void setBasis( ref btMatrix3x3 basis )
		{
			m_basis = basis;
		}