1 Attachment(s)
[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
- ØØ -
Re: Calculate coordinates...
Does the first line between the dots intersect the green line at 90 degrees?
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.
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.
- ØØ -
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...
- ØØ -
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.
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)
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.
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
- ØØ -