public Point3D ProjectionOnAxis(Point3D axis) { if (axis.Norm() < double.Epsilon) { throw new Exception("Axis length shouldn't be 0"); } return(axis * axis.MultiplyScalar(this) / Math.Pow(axis.Norm(), 2)); }
public static Angle AngleBetweenVectors(Point3D firstVector, Point3D secondVector) { if(firstVector.IsEmpty || secondVector.IsEmpty) throw new ArgumentException("Vectors cannot be null-vector when calculating angle"); var cos = firstVector.MultiplyScalar(secondVector) / (firstVector.Norm() * secondVector.Norm()); if(Math.Abs(cos) > 1) cos = Math.Sign(cos) * 1; return Acos(cos); }
public static Angle AngleBetweenVectors(Point3D firstVector, Point3D secondVector) { if (firstVector.IsEmpty || secondVector.IsEmpty) { throw new ArgumentException("Vectors cannot be null-vector when calculating angle"); } var cos = firstVector.MultiplyScalar(secondVector) / (firstVector.Norm() * secondVector.Norm()); if (Math.Abs(cos) > 1) { cos = Math.Sign(cos) * 1; } return(Acos(cos)); }
public Point3D ProjectionOnAxis(Point3D axis) { if (axis.Norm() < double.Epsilon) throw new Exception("Axis length shouldn't be 0"); return axis*axis.MultiplyScalar(this)/Math.Pow(axis.Norm(), 2); }