With the FlexPainter addon the castings are done orthogonal to the base entities.
I mainly used two functions for that:
shape.getPointWithDistanceToStart () & shape.getAngleAtPoint ()
It now seems that I struggled with the same issues as Robert S. back in 2017.
See Ucs.js; Polys don't have an angle at them. (indeed, not one unique)
The easiest where Arcs and Lines.
These will return an angle even if the point is not on the entity itself anymore.
Casting at distance 10 will return an angle even if the entity is only 9 long.
Being errorless was handy in testing.
shape.getAngleAtPoint (passed endings) = no error
Circles don't have these functions. (or I missed them)
The equation for a circle circumfence is straightforward:
O = 2*pi*r and directly related to a distance and an angle.
Open splines did not oppose much problems beside the fact that they freeze at the end.
Casting at distance 10 on 9 long returns the angle at the endpoint.
shape.getAngleAtPoint (passed EndPoint) = angle at EndPoint
Solution: Simply don't cast beyond the endings as it is that what we intend to do.
Logical open Geo closed splines return the end angle at the begin.
shape.getAngleAtPoint (StartPoint) = angle at EndPoint
Solution: Tiny little offset from start.
And now come my favorite troublesome ones....
To get an angle at a poly first the nearest segment is addressed.
shape.getSegmentAt(shape.getClosestSegment(a point on the poly))
At a vertex this will be the next segment in line.
Ok, a matter of general agreement.
Polys are strickt, traversing any ending result in an error.
Logical open Geo closed polys return the begin angle at the end.
Pritty correct as here the next segment is the first again.
Solution: tiny little offset from end.
But that was not enough.
Found that I needed to increase the tiny bit to at least 1000 times RS.PointTolerance,
or 1.0E-6, to get far enough from start=end to not select the first segment.
On closed forms going further past the end is handled as if it restarts overnew past start.
Casting is partially multisumming distances with the limited arithmetic accuracy.
And then suddenly a freak bug.
On closed polys casting something like 4.0E-14 distance short from the end also opposed a problem.
Closed Form here means Logi or Geo closed and pritty continuously connected.
Solution: very near end = end
You may notice the similarity/duality with the former solution.
As these are continuously connected it doesn't matter much to pick the first or last segment.
We might debate these buggy-likes but I stopped in doing that.
I see an agreement emerging with all my 'offset to poly' problems.
I had tons off them set aside before I wiped.
And we can't trace the origin.
Recently I put a dxf aside where I could not cast a proper offset.
See Attached dxf
Have a go at it.
Classified as 'expected behaviour'.
Drop in here to discuss whatever you want.
1 post • Page 1 of 1