/// <summary> /// Test if both vectors are equal. /// </summary> /// <param name="obj">The object the equality is tested with.</param> /// <returns></returns> public override bool Equals(object obj) { V3D v3d = (V3D)obj; return(IsEqual(X, v3d.X) && IsEqual(Y, v3d.Y) && IsEqual(Z, v3d.Z)); }
/// <summary> /// Returns cross product. /// </summary> /// <param name="a">A vector.</param> /// <returns>Cross product.</returns> public V3D Cross(V3D a) => new V3D(Y * a.Z - Z * a.Y, Z * a.X - X * a.Z, X * a.Y - Y * a.X);
/// <summary> /// Returns the vector between a and b that divides vector (a - b) in t ratio. For zero it's a, for 1 it's b. /// </summary> /// <param name="a">Vector a.</param> /// <param name="b">Vector b.</param> /// <param name="t">A number between 0 and 1.</param> /// <returns>the vector between a and b that divides vector (a - b) in t ratio. For zero it's a, for 1 it's b.</returns> public static V3D Interpolate(V3D a, V3D b, double t) => new V3D(a.X * (1.0 - t) + b.X * t, a.Y * (1.0 - t) + b.Y * t, a.Z * (1.0 - t) + b.Z * t);
/// <summary> /// Returns dot product. /// </summary> /// <param name="a">A vector.</param> /// <returns>Dot product.</returns> public double Dot(V3D a) => X * a.X + Y * a.Y + Z * a.Z;