It’s ok if the component doesn’t run if the point is not in the plane of the circle, but it only happens if it’s in a positive direction from the normal direction of the plane, in a negative direction it does something strange.
private void RunScript(Circle circle, Point3d point, ref object A, ref object B)
{
Plane plane = circle.Plane;
double radius = circle.Radius;
point.Transform(Transform.PlanarProjection(plane));
Point3d pt = Point3d.Unset;
plane.RemapToPlaneSpace(point, out pt);
double dx = pt.X;
double dy = pt.Y;
double d = Math.Sqrt(dx * dx + dy * dy);
double a = Math.Asin(radius / d);
double b = Math.Atan2(dy, dx);
double ta = b + a;
double tb = b - a;
Point3d pa = plane.PointAt(radius * Math.Sin(ta), radius * -Math.Cos(ta));
Point3d pb = plane.PointAt(radius * -Math.Sin(tb), radius * Math.Cos(tb));
A = new Line(pa, point);
B = new Line(pb, point);
}
I don’t think so. It’s not a tolerance-dependent algorithm. It has an exact solution. And it’s also not related to whether it changes its behavior above or below the plane. It looks like a bug, or at least a partially handled invalid situation.
I believe all modeling software is highly dependent on the tolerance accepted in the approximation algorithms it has. Trigonometry or not, the values are approximated to a certain floating number. truncated at some point leading to errors. A slight move of the point on a circle (depending on rounding) could lead to big angle error. But I may as well be wrong.
As I understand it, the problems relating to tolerances are the problems relating to limits, mathematically speaking. Computationally you can’t approximate a solution infinitesimally, so you need a tolerance to set a threshold that makes the limit reasonable. Intersections need this to set a resolution or accuracy for it to be profitable to use them, they are numerical solutions. Mathematical operations like trigonometry, do not need this they are fast enough and are considered analytical solutions. Using System.double you have ~15-17 digits of accuracy, if you used System.decimal you would have 28-29 digits. If they run fast with such precision, you don’t need to catch your result before it temporarily explodes.
I don’t know what is the code behind that component. If you project the point on the plane of the circle before hooking it to the tangent line component it works fine.