How can I find a point is left or right of an oriented curve inMatlab?

Discussion in 'MATLAB' started by Eric, Mar 29, 2008.

  1. Eric

    Eric Guest

    for example, I have a array describing a curve from start to end, and
    there is a point beside.

    So I want to know the point is left or right of this curve, how can I
    get it from Matlab?

    Thanks!
     
    Eric, Mar 29, 2008
    #1
    1. Advertisements

  2. Eric

    Daniel Guest

    My guess is that this is going to have to be done
    mathematically.

    You are going to have to analyze your array and then check
    the point.
     
    Daniel, Mar 29, 2008
    #2
    1. Advertisements

  3. Eric

    Eric Guest

    so how about this idea? For example, I add this point at the beginning
    or end of the array which was an unclosed curve. And now I treat this
    curve as a closed curve, so I just need find this closed curve is
    clockwise or anti-clockwise.

    When it is clockwise, I can say that the point is right of the unclose
    curve; if it is anti-clockwise, which means the point is left of the
    unclose curve.

    But how to find a closed curve represented by an array is clockwise or
    anti-clockwise, is another problem in Matlab, isn't it?
     
    Eric, Mar 29, 2008
    #3
  4. <8ec08dd5-749e-4287-9eae-
    >...
    ---------
    If your array describes a closed curve (which doesn't cross itself,) you can
    use matlab's 'inpolygon' function.

    If the curve is not closed, I claim the question is not well-defined. Imagine
    that you start with a point which could be regarded as lying to the immediate
    "left" of the curve. Let the point follow some path that eventually winds up
    being on the opposite side of the curve to its immediate "right" side without
    the path ever crossing the curve. Then ask yourself this question: "at what
    precise place in this path has the point changed from being on one side of
    the curve to being on its other side?" The answer to that certainly isn't clear
    to me.

    You can answer the following question unambiguously: for any directed line
    segment, is the triangle formed by the point and the two segment endpoints
    traversed clockwise or counterclockwise if travel is in the same direction as
    on the line segment? Of course for all the segments of the curve both cases
    may occur in general, but if the point lies near the curve, its nearest segment
    could be considered to give the answer as to the side, though the decision as
    to which segment is closest could itself be a little vague. As the point moves
    away from the curve this question becomes increasingly vague.

    Roger Stafford
     
    Roger Stafford, Mar 29, 2008
    #4
  5. Eric

    Eric Guest

    In fact, in a simple situation, the closed curve method does work.

    And I found a Matlab function "varea" which can distinguish clockwise
    curve from anti-clockwise curve, it is enough to my work.

    Thanks!
     
    Eric, Mar 30, 2008
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.