How to calculate four points...?

Discussion in 'C' started by rakeshthp, Aug 12, 2009.

  1. rakeshthp

    rakeshthp New Member

    Joined:
    Aug 8, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Hi guys...

    One more problem.. Do let me know if this post doesnt belong to this category.. If so, den which category it belongs.. Coz am writing c++ programs to solve it... Anyhow, Pls refer to the image diagram attached along this post..

    You will find 5 points.. I need to calculate points a, b, c and d.. SO i thought i would begin by finding points a, d

    lengths (Pa) = (Pd), is not constant.. it may vary every time.. it is called "along boundary length".. So, for a given along boundary length, i need to find these two points a, and d, with respect to P in such a way that,

    and points a and d must lie on any of the line segments..

    First way i thought was to find the tangent(shown in green), of "along boundary length" and get two end points.. from these two end points i can draw a line which will intersect the arc, and i can get values of "a" and "d"... But now i feel this logic is having some fault..

    Now am stuck up.. My ultimate goal is to find values of points a, b, c and d for given set of inputs:

    1. Point P
    2. along boundary length l(Pa), l(Pd)
    3. off boundary length l(ab), l(cd)

    Any way to get this solved..??

    Thanks in advance
     

    Attached Files:

  2. mayjune

    mayjune New Member

    Joined:
    Jun 14, 2009
    Messages:
    814
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Pune,Delhi
    Your question is way too unclear...
    what is along and off boundary length? Does a b c d have to be in some form or any shape?
    Please post the exact question you are suppose to solve, so that we can understand properly
     
  3. rakeshthp

    rakeshthp New Member

    Joined:
    Aug 8, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Ok.. The line drawn is assumed to be a boundary (assume it as ocean boundary or Great wall of china).. and the along-boundary length is the distance between point P and point a & point P and point d..

    off-boundary length means the distance away from the boundary.. in this case distance between point p and mid point of line bc..

    Actually, the flow goes something like this.. In this system:

    1) user will first input the points of the arc(connected line).. Using these points, connected line is drawn.. Among these points one point is point P..

    2) Next user will define a region to perform some operation. This region is defined by

    i) Inputting the point of interest around which the region is defined. Here in our example, point P is the point of interest, where user wants to define a region.
    ii) Inputting the along-boundary length. Using this length, we need to find the points A and D..
    iii) Inputting the off-boundary length.. Once Points A and D are estimated, next step is to estimate, points B and C in such a way that distance of point P and mid-point(BC) is equal to the off-boundary length. And these two points need to be perpendicular to point of interest P.

    3) After estimating all four points, users region is defined. And this region has to be in a rectangular shape.

    4) Once the area is defined, further processing is done..

    Any more queries, then pls feel free to ask.. I hope this information makes my problem understandable.....
     
  4. mayjune

    mayjune New Member

    Joined:
    Jun 14, 2009
    Messages:
    814
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Pune,Delhi
    don't know im having hard time understanding your question, moreover i dont get what you are trying to do nor whats the purpose of your program....i guess someone else should try answering to you...
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    First a couple of things don't make sense. You can't have a tangent
    to a point, and you can only be perpendicular to a line, not a point.

    For what you call a tangent to P, are you taking a line through P that is
    parallel to the line AD? That is OK.

    Also if the midpoint of the line BC is the "off boundary length" L1 distance
    from P, you can find that by bisecting the angle aPd and taking the distance
    L1 along that line. You can draw parallel lines to that which pass through A
    and D:

    Code:
    X
    |   d------------c------Y
    |  /             |
    | /              |
    |/               |
    P----------------W--------- bisecting line of aPd
    |\               |
    | \              |
    |  \             |
    |   a------------b------Z
    |
    
    W is distance L1 from P.
    Line through PX is perpendicular to PW, or to ad whichever you prefer.
    dY and aZ parallel to PW
    Line cWb is perpendicular to PW, or parallel with PX, whichever is easier.
     
  6. rakeshthp

    rakeshthp New Member

    Joined:
    Aug 8, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Pardon my language.. Sorry for using wrong terms.. What i meant to say is that, i need BC to be drawn parallel to a line, of which Point P is part of.. I mean, at angle of 90 degree..

    The result should be similar to the one shown by you..

    i mean the distance between point P and line BC should be equal to the off boundary length..

    Yes... But i need not store values of W.. Rather i can make use of this point to calculate B and C if there is any way to do that...

    Yes we can assume that.. coz in my problem line PX does not exists.. I was just trying to solve, by

    1) trying to find the line (X1X2) of length 2(off boundary length) Here we'll get two end points of this new line..
    2) Using these end points, i can draw two more lines, which intersect any of two line segments from the set of line segments.. (as shown in diagram below)

    Code:
          /
    X1   /
    |---d------------
    |  /             
    | /              
    |/               
    P
    |\               
    | \              
    |  \             
    |---a------------
    X2   \
          \
    
    3) then based on a and d, we can estimate b and c..

    So i had just drawn that line.. It has nothing to do with my problem.. This method got some flaw.. Which i came to know later.. coz length PX2 is not equal to length Pa..

    i guess it's not becoming more complicated.. My problem is my poor explanation method..
     
  7. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Is the border of the area you wish to calculate PabcdP?

    > i mean the distance between point P and line BC should be equal to the off boundary length

    OK, but at what angle? Will angles dPW and aPW in my diagram be equal, and will the line PW bisect the angle aPd? All points distance L1 from P will describe a circle around P of radius L1 so how do you know which direction to go on?
     
  8. rakeshthp

    rakeshthp New Member

    Joined:
    Aug 8, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    suppose we draw an virtual line from "d" to "a", then, line BC must be parallel to this virtual line AD...

    Yes..

    Thanks
     
  9. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Code:
    X
    |   d------------c------Y
    |  /             |
    | /              |
    |/               |
    P----------------W--------- bisecting line of aPd
    |\               |
    | \              |
    |  \             |
    |   a------------b------Z
    |
    
    OK, so where are you up to with this?

    I would suggest that the first place to start is to bisect angle dPa
    (which, with polar co-ords representing Pd and Pa as vectors from P,
    can be done by averaging the two theta values of Pd and Pa).

    Then you can calculate point W as a polar offset from P: you've got theta
    from the previous calculation, and r is just the off-boundary distance.

    Line cWb is the perpendicular to line PW and you can find formulae to
    calculate perpendicular lines easily enough; try Googling some relevant
    terms and see what you come up with.

    Line dY is parallel to PW and passes through point d, and again a
    formula to get a line parallel to another and passing through a known
    point should be easy enough to find. The intersection (again, for
    formulae, Google it) of the last two lines (i.e. Wc and dc) gives you
    the location of c, and then just mirror this lot to find.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice