コード例 #1
0
ファイル: Point3D.cs プロジェクト: FoKycHuK/CVARC
 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));
 }
コード例 #2
0
ファイル: Vectors.cs プロジェクト: DmitryZyr/CVARC
 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);
 }
コード例 #3
0
        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));
        }
コード例 #4
0
ファイル: Point3D.cs プロジェクト: DmitryZyr/CVARC
 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);
 }