Hi,
I am using PerpendicularFrameAt() method to generate perpendicular vectors from the segments of a polyline in WorldXY Plane and VectorAngle method to calculate angles between two lines or vectors.
While debugging I came across some discrepancies in the vector values of the perpframe that i get back.
These errors in the values are causing some issues down the track for me and I was wondering the cause of it and how can I avoid these?
Something similar happens with VectorAngle method where the angle returned and converted to degrees has a trailing decimal value (example : 90.000000015) but I am unable to recreate it for now.
PerpFrame_test.3dm (35.2 KB)
PerpFrame_test.gh (7.5 KB)
Line direction is parallel to World XAxis but perpframe X-axis seems to be slightly off
The issues you’re seeing are due to floating-point precision limitations. For more details, check out Floating Point Arithmetic.
To minimize these problems, set your script to directly accept a Curve as input.
Srujan.gh (6.4 KB)
Hi @Mahdiyar thanks for getting back.
I was under the impression LineCurve behaves the same as a Curve.
I have a constructor like so -
public BoundarySegment(Line segment, int index, bool isOuterBoundary)
{
_boundarySegment = segment;
Index = index;
IsOuterBoundary = isOuterBoundary;
var segmentLineCurve = new LineCurve(segment);
segmentLineCurve.PerpendicularFrameAt(0.5, out Plane slcPerpFrame);
var slcPerpFrameXAxis = new Vector3d(slcPerpFrame.XAxis);
OutwardVector = slcPerpFrameXAxis;
}
OutwardVector property stores the perpendicular vector in question. I use that to move or offset the segment down the track. Any suggestions for avoiding floating point errors in this case and a get a clean vector output?