/// <summary> /// Equality for quaternions /// </summary> public bool Equals(Quaternion other) { if (other.IsNan && IsNan || other.IsInfinity && IsInfinity) { return(true); } return(Real.AlmostEqual(other.Real) && ImagX.AlmostEqual(other.ImagX) && ImagY.AlmostEqual(other.ImagY) && ImagZ.AlmostEqual(other.ImagZ)); }
/// <summary> /// returns quaternion as real+ImagXi+ImagYj+ImagZk based on format provided /// </summary> public string ToString(string format, IFormatProvider formatProvider) { return(string.Format(formatProvider, "{0}{1}{2}i{3}{4}j{5}{6}k", Real.ToString(format, formatProvider), (ImagX < 0) ? "" : "+", ImagX.ToString(format, formatProvider), (ImagY < 0) ? "" : "+", ImagY.ToString(format, formatProvider), (ImagZ < 0) ? "" : "+", ImagZ.ToString(format, formatProvider))); }