mardi 23 décembre 2014

Algorithm for sweeping a 2d shape along a curve?


I am trying to create a graphics application where the user can use an arbitrary shape as a "brush", which will be swept along the drawing path. The shape may be transformed along the path (rotated, resized, etc).


I read this paper, and it seemed promising: Approximate General Sweep Boundary of a 2D Curved Object


My understanding of the method is this:



  1. Simplify the shape to a polygon

  2. Sample the shape at various times t along the curve

  3. For each t, connect each point of the polygon at t the corresponding point of the polygon at t-1

  4. Calculate the convex hull of the joined shapes

  5. Move to t+1


Do I have it right? Is this the best way to approach this problem?


To clarify what I mean by a "Sweep Boundary": Examples would include a pen writing a line, Zorro marking the wall with his sword, a magic marker on a mirror. In each of these cases, there is a path that defines the movement (the "Heartline") and a shape that defines the width and angle of the writing instrument (the "Counterpoint"). The counterpoint is independent of the heartline and can change at any point t along the path.


The path would be "convex" only in the sense that an envelope is formed by the counterpoint as it "travels" along the heartline.





Aucun commentaire:

Enregistrer un commentaire