Bug introduced in 10.4 or earlier and persisting through 11.2
CASE:2326540
Solution: Wait and use N
meanwhile.
I've faced this problem writing an answer for Animate point go round a triangle.
For coordinates with exact values, instead of moving along a multi-line LineScaledCoordinate
is mooving along extrapolated first segment.
It is not always the case but always for exact values. N
is the fix.
Needs["GraphUtilities`"]
vertices = {{0, 0}, {1, 0}, {1, 2}, {2, 1}};
Slider[Dynamic@t]
Graphics[{
EdgeForm@Thick, FaceForm@None, Polygon@vertices
,
AbsolutePointSize@12, Red, Dynamic[Point[LineScaledCoordinate[vertices, t]]]
,
AbsolutePointSize@12, Blue, Dynamic[Point[LineScaledCoordinate[N@vertices, t]]]
},
PlotRange -> {{0, 4.5}, {0, 4.5}}, Frame -> True
]
Answer
Internally LineScaledCoordinate
use
Position[d, _?(#1 >= t &)]
to detect a current segment. Here d
is an accumulated list of distances (relative to the total length of segments). However, algebraic expressions are not atomic:
t = 0.5;
d = {0, 1/(3 + Sqrt[2]), 3/(3 + Sqrt[2]), 1};
Position[d, _?(#1 >= t &)]
Position[N@d, _?(#1 >= t &)]
(* {{2, 1, 1}, {2, 1, 2, 1}, {2, 1, 2, 2}, {2, 1, 2}, {2,
1}, {3, 1}, {3, 2, 1, 1}, {3, 2, 1, 2, 1}, {3, 2, 1, 2, 2}, {3, 2,
1, 2}, {3, 2, 1}, {3}, {4}} *)
(* {{3}, {4}} *)
Comments
Post a Comment