/// <summary> /// Returns the length (magnitude) of this vector. /// </summary> /// <returns>The length of this vector.</returns> public double Length() { double x2 = x * x; double y2 = y * y; double z2 = z * z; return(Mathd.Sqrt(x2 + y2 + z2)); }
public static Vector4d AxisAngle(Quatd q) { double angle = 2 * Mathd.Acos(q.w); double den = Mathd.Sqrt(1 - q.w * q.w); if (den == 0) { return(new Vector4d(0, 0, -1, angle)); } return(new Vector4d(q.x / den, q.y / den, q.z / den, angle)); }
internal void Normalize() { double lengthsq = LengthSquared(); if (lengthsq == 0) { x = y = 0f; } else { double length = Mathd.Sqrt(lengthsq); x /= length; y /= length; } }
/// <summary> /// Returns the length (magnitude) of this vector. /// </summary> /// <returns>The length of this vector.</returns> public double Length() { return(Mathd.Sqrt(x * x + y * y)); }
/// <summary> /// Returns the distance between this vector and `to`. /// </summary> /// <param name="to">The other vector to use.</param> /// <returns>The distance between the two vectors.</returns> public double DistanceTo(Vector2d to) { return(Mathd.Sqrt((x - to.x) * (x - to.x) + (y - to.y) * (y - to.y))); }