Exemple #1
0
		public static void SetRotation(ref Matrix m, Quaternion q)
		{
			float d = q.LengthSquared();
			BulletDebug.Assert(d != 0);
			float s = 2f / 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;
			m = new Matrix(1 - (yy + zz), xy - wz, xz + wy, 0,
							xy + wz, 1 - (xx + zz), yz - wx, 0,
							xz - wy, yz + wx, 1 - (xx + yy), 0,
							m.M41, m.M42, m.M43, 1);
		}
Exemple #2
0
 public void LengthSquared()
 {
     Quaternion q1 = new Quaternion(1, 2, 3, 4);
     Compare(30.0f, q1.LengthSquared());
 }