/// <summary> /// Constructs a quaternion that will rotate around the given axis /// by the specified angle. The axis must be a normalized vector. /// </summary> /// <param name="axis">The axis to rotate around. Must be normalized.</param> /// <param name="angle">The angle to rotate, in radians.</param> public Quatd(Vector3d axis, double angle) { #if DEBUG if (!axis.IsNormalized()) { throw new ArgumentException("Argument is not normalized", nameof(axis)); } #endif double d = axis.Length(); if (d == 0f) { x = 0f; y = 0f; z = 0f; w = 0f; } else { double sinAngle = Mathd.Sin(angle * 0.5f); double cosAngle = Mathd.Cos(angle * 0.5f); double s = sinAngle / d; x = axis.x * s; y = axis.y * s; z = axis.z * s; w = cosAngle; } }
public Planed Normalized() { double len = _normal.Length(); if (len == 0) { return(new Planed(0, 0, 0, 0)); } return(new Planed(_normal / len, D / len)); }
public Quatd(Vector3d axis, double angle) { double d = axis.Length(); double angle_t = angle; if (d == 0f) { x = 0f; y = 0f; z = 0f; w = 0f; } else { double s = Mathd.Sin(angle_t * 0.5f) / d; x = axis.x * s; y = axis.y * s; z = axis.z * s; w = Mathd.Cos(angle_t * 0.5f); } }
public static Vector4d DirMag(Vector3d v) { return(new Vector4d(v.Normalized(), v.Length())); }