Skip to content
This repository has been archived by the owner on Dec 23, 2020. It is now read-only.

Why Rhino.Geometry.Vector3d.VectorAngle returns (2π - angle)? #178

Open
goznauk opened this issue Jul 11, 2017 · 0 comments
Open

Why Rhino.Geometry.Vector3d.VectorAngle returns (2π - angle)? #178

goznauk opened this issue Jul 11, 2017 · 0 comments

Comments

@goznauk
Copy link

goznauk commented Jul 11, 2017

public static double VectorAngle(Vector3d a, Vector3d b, Plane plane)
    {
      Point3d testPoint1 = plane.Origin + a;
      Point3d testPoint2 = plane.Origin + b;
      Point3d point3d1 = plane.ClosestPoint(testPoint1);
      Point3d point3d2 = plane.ClosestPoint(testPoint2);
      a = point3d1 - plane.Origin;
      b = point3d2 - plane.Origin;
      if (!a.Unitize() || !b.Unitize())
        return -1.23432101234321E+308;
      double d = a * b;
      if (d >= 1.0)
        d = 1.0;
      else if (d < -1.0)
        d = -1.0;
      double num = Math.Acos(d);
      if (Math.Abs(num) < 1E-64)
        return 0.0;
      if (Math.Abs(num - Math.PI) < 1E-64)
        return Math.PI;
      Vector3d other = Vector3d.CrossProduct(a, b);
      if (plane.ZAxis.IsParallelTo(other) == 1)
        return num;
      return 2.0 * Math.PI - num;
    }

This is what I've found in Rhino.Geometry.Vector3d.VectorAngle(Vector3d a, Vector3d b, Plane plane).
I don't know why we should get (2π - angle) in most cases - when the input plane is not the plane contains both a and b. Is there any reason for this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant