determine offset point

S

some one

Does anyone know the algorithm or a function out there that will
compute the offset location given the following:
inputs:
1) x,y coordinate of starting point
2) angle (bearing)
3) distance to offset point
outputs:
1) x,y coordinate of destination

thanks
 
M

Mark A. Odell

(e-mail address removed) (some one) wrote in

Does anyone know the algorithm or a function out there that will
compute the offset location given the following:
inputs:
1) x,y coordinate of starting point
2) angle (bearing)
3) distance to offset point
outputs:
1) x,y coordinate of destination

Do you have a question about the C language or did you mean to post in
comp.programming instead?
 
J

Joona I Palaste

some one said:
Does anyone know the algorithm or a function out there that will
compute the offset location given the following:
inputs:
1) x,y coordinate of starting point
2) angle (bearing)
3) distance to offset point
outputs:
1) x,y coordinate of destination

You know, for mathematics questions, there's always sci.math. Your
question is completely irrelevant to comp.lang.c. Anyway...
Suppose your variables are as follows:
1) x=x coordinate of starting point, y=y coordinate of starting point
2) theta=angle (bearing)
3) r=distance to offset point
Now the output:
x' = x coordinate of destination = x + r*cos(theta)
y' = y coordinate of destination = y + r*sin(theta)
Those formulas work right away as C expressions, given that you've
declared the variables as doubles and #included <math.h>.

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"The large yellow ships hung in the sky in exactly the same way that bricks
don't."
- Douglas Adams
 
M

Martin Ambuhl

some said:
Does anyone know the algorithm or a function out there that will
compute the offset location given the following:
inputs:
1) x,y coordinate of starting point
2) angle (bearing)
3) distance to offset point
outputs:
1) x,y coordinate of destination

This is not a C question, but an elementary math question.
Even though off-topic here, the answer is short.

x_new = x_old + dist * cos(angle);
y_new = y_old + dist * sin(angle);

Since this trivial math is unknown to you, you are sure to use the wrong
measurement for the angle. Get an elementary math book and check your
documentation for the sin() and cos() function before you post a question
because you didn't express the angle in radian measure.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,138
Messages
2,570,804
Members
47,349
Latest member
jojonoy597

Latest Threads

Top