Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: 2D Path - Trace along each side.

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    1

    2D Path - Trace along each side.

    Hi,

    I have a 2d path made up of points. I would like to take this path and expand it either side to make it look more like a 2d topdown view of a road.

    Original Path

    ---------

    Wanted Outcome

    ---------

    ---------

    See how now two paths exist either side of where the original once was.

    Does this sort of manipulation have a name?

    I hope this makes sense.

    Kind Regards
    Jayson

  2. #2
    Member Regular Contributor DmitryM's Avatar
    Join Date
    Mar 2009
    Location
    Toronto
    Posts
    436

    Re: 2D Path - Trace along each side.

    It doesn't seem to be difficult.
    All you need is to approximate the normal at each point. Then shift along a constant distance on it and put the second path point.

    If you have an original line as X(t),Y(t), then the tangent is dX(y),dY(t) and the normal is dY(t),-dX(t).

  3. #3
    Member Regular Contributor strattonbrazil's Avatar
    Join Date
    Jun 2007
    Location
    Los Angeles, CA
    Posts
    306

    Re: 2D Path - Trace along each side.

    Um, not sure the name of whatever you're trying to do, but I think I can help. Several papers try to build polygons from a point curve. It's very common for art programs like photoshop. One paper you might want to read is "Skeletal Strokes". You can skip most of it and jump down to the part where it talkes about the 3 joint types. You can implement it all just by following the diagram for which joint you use.

    I did a rough implementation of it a bit ago here. It's in scala, but should be pretty easy to read.
    http://code.google.com/p/inkspot/source/...roke.scala?r=47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •