6
$\begingroup$

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
 ]

enter image description here

$\endgroup$
4
$\begingroup$

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}} *)
| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks for your time. So you agree it is a bug, right? $\endgroup$ – Kuba Jan 24 '15 at 21:41
  • $\begingroup$ @Kuba Yes! The level specification in Position was missed. $\endgroup$ – ybeltukov Jan 24 '15 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.