Esempio n. 1
0
		public static Quaternion Blend(float t, Quaternion a, Quaternion b)
		{
			float norm = Quaternion.Dot(a, b);
			bool flip = norm < 0;
			if (flip) norm = -norm;

			float inv_t;
			if (1 - norm < 1e-6f)
				inv_t = 1 - t;
			else
			{
				float theta = (float)Math.Acos(norm);
				float s = (1 / (float)Math.Sin(theta));
				inv_t = (float)Math.Sin((1 - t) * theta) * s;
			}

			if (flip)
				t = -t;

			return new Quaternion(
				inv_t * a.x + t * b.x,
				inv_t * a.y + t * b.y,
				inv_t * a.z + t * b.z,
				inv_t * a.w + t * b.w);
		}
Esempio n. 2
0
		public static float Dot(Quaternion a, Quaternion b)
		{
			return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
		}
Esempio n. 3
0
		public Transform(Quaternion r, Vector3 t)
		{
			rotation = r;
			translation = t;
		}