6

Referring to this link I happen to realize that actually the trace being projected is dependent on an equation and not on disk or circle. Though I was presuming that it is getting traced because of the movement of circle/disk. So, in mathematica is it possible that the object can be traced automatically, say the same output of cycloid program without using parametric equations for trace of point on circle.

Pankaj Sejwal
  • 2,063
  • 14
  • 23
  • 2
    You could extract the coordinates for elements in a graph if they are unique, say there is only one Disk[] in the graph. Ideally you'd need a way to tag the points you may want to extract later but I don't think there is a way to attach such labels to Mathematica Graphics elements. One possible solution would be to Sow[] the information as you build up the plot, then Reap[] the information you need later if you choose to. – SEngstrom May 11 '13 at 16:16
  • You could always use a particle filter... :D – rm -rf May 11 '13 at 16:18
  • @rm-rf: can you elaborate more on this particle filter concept? – Pankaj Sejwal May 11 '13 at 16:28
  • 1
    @rafiki It was a little tongue-in-cheek... While it is true that particle filters are very useful in real world tracking applications (see this video of the man with a glowing butt, for an example), it is overkill for the application you suggest. Something like what SEngstrom suggested (extract coordinates of interest) is what I would do as well. – rm -rf May 11 '13 at 16:36
  • kguler's answer to that question does not use the parametric equations. As far as you know how your object is going to translate and rotate, you can find the trace his way without resorting to image processing or knowing the math. – C. E. May 12 '13 at 14:57
  • @Anon: I have seen both kinds of code one that uses rotation and other that uses parametric equations. But it was not very clear to me. – Pankaj Sejwal May 12 '13 at 15:12
  • 1
    @rm-rf A particle filter ... kind of http://reference.wolfram.com/mathematica/ref/ImageFeatureTrack.html (see "Neat Examples") – Dr. belisarius May 12 '13 at 19:38

1 Answers1

9
h = {Disk[], Red, PointSize[Large], Point[{1, 0}]};
r = Image@Total[ImageData /@ (ColorSeparate /@ 
               Table[
                      Graphics[{Translate[Rotate[h, - 2 t/(Pi)], {t, 0}]}, 
                                 PlotRange -> {{0, 6 Pi}, {-1, 1}}, Background -> Black], 
                      {t, 0, 6 Pi, 2 Pi/20}])[[All, 1]]]

enter image description here

enter image description here

Edit (Perhaps cleaner)

(*the object to trace*)
h = {Disk[], Red, PointSize[Medium], Point[{1, 0}]};

obj[t_, col_] := Graphics[Translate[Rotate[h, -2 t/(Pi)], {t, 0}], 
                          PlotRange -> {{0, 6 Pi}, {-1, 1}}, Background -> col];
dt = Pi/20;

tr[0, dt] = First@ColorSeparate[obj[0, Black]];
tr[t_, dt_] :=  tr[t, dt] = ImageAdd[tr[t - dt, dt], First@ColorSeparate[obj[t, Black]]];

Animate[ ImageCompose[ImageMultiply[tr[t, dt], Red], {obj[t, White], .6}], {t, 0, 6 Pi, 2 Pi/20}]

enter image description here

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453