public MovableQuat(Matrix transform) { Matrix3 rotation = new Matrix3 (transform); m_rotation = rotation.getQuaternion (); m_position = transform.Translation; m_scale = new Vector3 (1.0f); }
public MovableQuat(Vector3 forward, Vector3 up, Vector3 position) { Matrix3 rotation = new Matrix3 (forward, up, true); m_rotation = rotation.getQuaternion (); m_position = position; m_scale = new Vector3 (1.0f); }
public EulerAngles(Matrix3 rotation) { float sineOfPitch = -rotation.Forward.Y; if (MuxMath.equals (Math.Abs (sineOfPitch), 1.0f)) { // pitched 90 or -90 m_pitch = MathHelper.PiOver2 * sineOfPitch; m_yaw = (float)Math.Atan2 (-rotation.Right.Z, rotation.Right.X); m_roll = 0.0f; } else { m_pitch = (float)Math.Asin (sineOfPitch); m_yaw = (float)Math.Atan2 (rotation.Forward.X, rotation.Forward.Z); m_roll = (float)Math.Atan2 (-rotation.Right.Y, rotation.Up.Y); } }
public Matrix4(Vector3 forward, Vector3 up, Vector3 translation, bool ensureOrthonormal) { M = new Matrix3 (forward, up, true); this.t = translation; }
public void transform(Quaternion q) { Matrix3 m = new Matrix3 (q); transform (m); }
internal static Matrix3 createYawPitchRollRad(float yaw, float pitch, float roll) { Matrix3 rotate = new Matrix3 (); rotate.setYawPitchRollRad (yaw, pitch, roll); return (rotate); }
// this = this * "m" public void postMultiply(Matrix3 m) { this *= m; }
public static void invert(ref Matrix3 m, out Matrix3 inverse) { Matrix3 copy = m; copy.invert (); inverse = copy; }
/************************************************************/ static Matrix3() { ms_identity = new Matrix3 (true); }
public Movable(Matrix3 rotation) { m_rotation = rotation; m_position = Vector3.Zero; m_scale = new Vector3 (1,1,1); }
public void billboard(Camera camera) { Vector3 forward = camera.Position - m_position; forward.Normalize (); Matrix3 billboard = new Matrix3 (forward, camera.Up); m_rotation = billboard.getQuaternion (); }
public Matrix4(Matrix3 m, Vector3 scale, Vector3 translation) { M = m; M.Right *= scale.X; M.Up *= scale.Y; M.Forward *= scale.Z; this.t = translation; }
public Matrix4(Matrix3 m, Vector3 translation, bool ensureOrthonormal) { M = m; m.makeOrthonormalCross (); this.t = translation; }
public Matrix4(Matrix3 m, Vector3 translation) { M = m; this.t = translation; }
public Matrix4(Quaternion q) { M = new Matrix3 (q); t = Vector3.Zero; }
/// Rotate about the local up axis public void yaw(float angleDeg) { Matrix3 rotate = new Matrix3 (); rotate.setRotateAxis (this.Up, angleDeg); m_rotation.Right *= rotate; m_rotation.Forward *= rotate; }
public Movable(Vector3 forward, Vector3 up, Vector3 position) { m_rotation = new Matrix3 (forward, up, true); m_position = position; m_scale = new Vector3 (1,1,1); }
public MovableQuat(Matrix3 rotation) { m_rotation = rotation.getQuaternion (); m_position = Vector3.Zero; m_scale = new Vector3 (1.0f); }
public Movable(MuxEngine.LinearAlgebra.Matrix4 xform) { m_rotation = xform.Rotation; m_position = xform.Translation; m_scale = new Vector3 (1,1,1); }
/// Rotate about the local right axis public void pitch(float angleDeg) { Matrix3 rotate = new Matrix3 (); rotate.setRotateAxis (this.Right, angleDeg); m_rotation.Up *= rotate; m_rotation.Forward *= rotate; }
public static Matrix3 createYawPitchRoll(float yawDeg, float pitchDeg, float rollDeg) { Matrix3 rotate = new Matrix3 (); rotate.setYawPitchRoll (yawDeg, pitchDeg, rollDeg); return (rotate); }
/// Rotate about "axis" through "p" public void rotateAboutPoint(Vector3 p, Vector3 axis, float angleDeg) { Matrix3 rotate = new Matrix3 (); rotate.setRotateAxis (axis, angleDeg); m_rotation *= rotate; m_position *= rotate; m_position += -p * rotate + p; }
public void decompose(out Vector3 scale, out Quaternion rotation) { EVector3 right = new EVector3 (this.Right); scale.X = right.normalize (); EVector3 up = new EVector3 (this.Up); scale.Y = up.normalize (); EVector3 forward = new EVector3 (this.Forward); scale.Z = forward.normalize (); Matrix3 m = new Matrix3 (right, up, forward); rotation = m.getQuaternion (); }
// Rotate about "axis" through origin public void rotateWorld(Vector3 axis, float angleDeg) { Matrix3 rotate = new Matrix3 (); rotate.setRotateAxis (axis, angleDeg); m_rotation *= rotate; m_position *= rotate; }
// this = "m" * this public void preMultiply(Matrix3 m) { this = m * this; }
/************************************************************/ public Movable() { m_rotation = Matrix3.Identity; m_position = Vector3.Zero; m_scale = new Vector3 (1,1,1); }
// this' = this * M; right-multiply matrix semantics public void transform(Matrix3 m) { float tx = X * m.Right.X + Y * m.Up.X + Z * m.Backward.X; float ty = X * m.Right.Y + Y * m.Up.Y + Z * m.Backward.Y; float tz = X * m.Right.Z + Y * m.Up.Z + Z * m.Backward.Z; X = tx; Y = ty; Z = tz; }
/// Rotate about world Y axis, preserving position public void rotateWorldY(float angleDeg) { Matrix3 rotate = new Matrix3 (); rotate.setRotateY (angleDeg); m_rotation *= rotate; }
// this' = this * M^(-1); right-multiply matrix semantics public void transformByInverse(Matrix3 m) { m.invert (); transform (m); }
public Matrix4(Vector3 forward, Vector3 up, Vector3 translation) { M = new Matrix3 (forward, up); this.t = translation; }