/// <summary> /// Initializes a new instance from a <see cref="UnitQuaternion"/>. /// </summary> /// <param name="quaternion">The quaternion.</param> public Matrix3By3(UnitQuaternion quaternion) { double x2 = quaternion.X * quaternion.X; double xy = quaternion.X * quaternion.Y; double xz = quaternion.X * quaternion.Z; double xw = quaternion.X * quaternion.W; double y2 = quaternion.Y * quaternion.Y; double yz = quaternion.Y * quaternion.Z; double yw = quaternion.Y * quaternion.W; double z2 = quaternion.Z * quaternion.Z; double zw = quaternion.Z * quaternion.W; double w2 = quaternion.W * quaternion.W; m_m11 = x2 - y2 - z2 + w2; m_m12 = 2.0 * (xy + zw); m_m13 = 2.0 * (xz - yw); m_m21 = 2.0 * (xy - zw); m_m22 = -x2 + y2 - z2 + w2; m_m23 = 2.0 * (yz + xw); m_m31 = 2.0 * (xz + yw); m_m32 = 2.0 * (yz - xw); m_m33 = -x2 - y2 + z2 + w2; }
/// <summary> /// Writes a value for the <c>rotation</c> property as a <c>unitQuaternion</c> value. The <c>rotation</c> property specifies the rotation to apply to the model node. If not specified, the default value is [0.0, 0.0, 0.0, 1.0]. /// </summary> /// <param name="value">The value.</param> public void WriteRotationProperty(UnitQuaternion value) { using (var writer = OpenRotationProperty()) { writer.WriteUnitQuaternion(value); } }
/// <summary> /// Writes the value expressed as a <code>unitQuaternion</code>, which is the rotation specified as a 4-dimensional unit magnitude quaternion, specified as `[X, Y, Z, W]`. /// </summary> /// <param name="value">The value.</param> public void WriteUnitQuaternion(UnitQuaternion value) { const string PropertyName = UnitQuaternionPropertyName; OpenIntervalIfNecessary(); Output.WritePropertyName(PropertyName); CesiumWritingHelper.WriteUnitQuaternion(Output, value); }
public Cartesian Rotate(UnitQuaternion rotation) { double w = rotation.W; double difference = w * w - rotation.X * rotation.X - rotation.Y * rotation.Y - rotation.Z * rotation.Z; double dot = m_x * rotation.X + m_y * rotation.Y + m_z * rotation.Z; return(new Cartesian(difference * m_x + 2.0 * (w * (m_y * rotation.Z - m_z * rotation.Y) + dot * rotation.X), difference * m_y + 2.0 * (w * (m_z * rotation.X - m_x * rotation.Z) + dot * rotation.Y), difference * m_z + 2.0 * (w * (m_x * rotation.Y - m_y * rotation.X) + dot * rotation.Z))); }