/// <summary> /// Projects this vector onto other vector. /// </summary> /// <param name="other">The vector being projected onto</param> /// <returns></returns> public DoubleVector3 ProjectOnto(DoubleVector3 other) { var numerator = other.Dot(this); var denominator = other.SquaredNorm2D(); return(new DoubleVector3( (other.X * numerator) / denominator, (other.Y * numerator) / denominator, (other.Z * numerator) / denominator)); }
/// <summary> /// result * other ~= Proj(this onto other) /// </summary> /// <param name="other"></param> /// <returns></returns> public double ProjectOntoComponentD(DoubleVector3 other) { return(other.Dot(this) / other.SquaredNorm2D()); }