Results 1 to 9 of 9

Thread: [RESOLVED] Calculate coordinates...

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Resolved [RESOLVED] Calculate coordinates...

    This looked like a very simple task. But for some reason I can't get my head around it at the moment. I need to calculate 3 coords in a 2D world. They will not always be in the first quadrant, so that has be to be taken into account (if it at all matters).

    If you look at the picture, you can see that the cayen colored sqare is a known coordinate. It has two blue lines going out from it. It is 45deg between them, but it might change so lets just call it A. It is at the moment 1unit to the first blue line (the length of the short green line), but this can also change, so lets call it L1, and it is aditionaly 5units to the next blue line (the length of the long green line), so that points is 6units from the cayen colored square. Now I need a formula to calcuate the position of the 4 red dots using A L1 and L2. Anyone care to help a tired head?

    Thanks in advance
    - ØØ -
    Attached Images Attached Images  

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Calculate coordinates...

    Does the first line between the dots intersect the green line at 90 degrees?

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Calculate coordinates...

    also, you need to know the angle of the structure relative to the x-axis. Otherwise, you don't know how to add the coordinate differences on.

  4. #4

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Calculate coordinates...

    Quote Originally Posted by penagate
    Does the first line between the dots intersect the green line at 90 degrees?

    Yeah, it does. The green lines are just imaginary lines though...just to tell you what and where we are.

    - ØØ -

  5. #5

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Calculate coordinates...

    Quote Originally Posted by penagate
    also, you need to know the angle of the structure relative to the x-axis. Otherwise, you don't know how to add the coordinate differences on.

    Forgot about that. I can makea vector that will devide the 45degree angle in exactly 2...so that way I can find the angle between that one and anyline I wan't. Then add 22.5 or subtract 22.5 to get the two long blue lines...

    - ØØ -

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Calculate coordinates...

    OK let's assume for the moment that the green line goes along the x-axis.
    The closest dots let's call P1 (above x-axis) and P2 (below), the further P3 and P4.
    The angle between the lines is you stated A.
    Let the bright cyan dot be (x,y).

    y{P1} / L1 = tan(A / 2),
    therefore y{P1} = L1*tan(A / 2),
    and y{P2} = -(L1*tan(A / 2)).

    x{P1,P2} = L1, so the coordinates of P1 and P2 are (adding to the origin)
    P1 (x+L1, y+L1*tan(A/2)); P2 (x+L1, y-L1*tan(A/2)).

    For P3 and P4 it is the same but you use L2 instead so
    coordinates are
    P3 (x+L2, y+L2*tan(A/2)); P4 (x+L2, y-L2*tan(A/2)).

    I think that's right...

    I'm trying to figure out how you would do it to allow for rotation.

  7. #7
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771

    Re: Calculate coordinates...

    I would say: The cyan dot, a red dot, and a green/black intersection form a triangle, calling these points C,R and I.
    The angle of I = 90 degrees, C is 1/2 A.
    The length RI = 1/2 Ln (L1 or L2, depending on which red dot you chose)
    Now you can calculate CR = RI * tan(C) = 1/2 Ln * tan(1/2 A)
    As far as I can tell you don't know how much the green lines or blue lines are rotated from the origin, lets call that angle theta for the red dots on the left (in your picture). Then:
    R1x = Cx + CR * cos(theta)
    R1y = Cy + CR * sin(theta)
    R2x = Cx + CR * cos(theta + A)
    R2y = Cy + CR * sin(theta + A)

  8. #8
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Calculate coordinates...

    I guess you are able to turn your figure in any direction, so let us assume your green line goes along the X-axis. That way you can calculate to coordinates for the points using A/2 as the angle to each point (I will only discuss the upper one).
    Since we turned the picture to have the green line along the X-axis, the X-coordinate for the length of the green Line (for the inner Point L1+the X-coordinateof the origin ).
    It is more difficult for the Y-coordinate. You the "Sinussatz" [German!, don't the english name of it]. First calculate the length of the line from the center to the point(Length). Using the sinussatz it is Length/Sin(90 degrees)=L1/sin(90-A/2).
    since Sin(90)=1, you have: Length=L1/sin(90-A/2).

    Knowing this Length you can calculate the Y-coordinate using Cos(A/2)*Lenght.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  9. #9

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: [RESOLVED] Calculate coordinates...

    Thanks, I managed to figgure it out when I saw twanvl post. And Opus Sinussatz helped a bit too..


    DoomSharp(); - Is greatfull.

    Thanks
    - ØØ -

Posting Permissions

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



Click Here to Expand Forum to Full Width