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 Point3D Projection(Point3D toProject, Point3D axis) { if (axis.IsEmpty) { throw new ArgumentException("Axis of projection cannot be null-vector"); } return((toProject.Norm() * Cos(AngleBetweenVectors(toProject, axis))) * axis.Normalize()); }
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); }
public static Point3D Projection(Point3D toProject, Point3D axis) { if(axis.IsEmpty) throw new ArgumentException("Axis of projection cannot be null-vector"); return (toProject.Norm() * Cos(AngleBetweenVectors(toProject, axis))) * axis.Normalize(); }