473,385 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

determine offset point

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
Nov 14 '05 #1
3 4658
fr********@yahoo.com (some one) wrote in
news:54*************************@posting.google.co m:
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?

--
- Mark ->
--
Nov 14 '05 #2
some one <fr********@yahoo.com> scribbled the following:
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 (pa*****@cc.helsinki.fi) ------------- 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
Nov 14 '05 #3
some one wrote:
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.


--
Martin Ambuhl
Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: siliconmike | last post by:
I'm just lost here.. Is there a function to determine current time on the client's computer clock ? Links / Pointers? Mike
4
by: Gactimus | last post by:
Here is a program that encodes and decodes a text file. What I need to do is write a C++ program that requests 3 different file names. One filename is for the source file to be encoded, another is...
0
by: D. Dante Lorenso | last post by:
I need to know that original number of rows that WOULD have been returned by a SELECT statement if the LIMIT / OFFSET where not present in the statement. Is there a way to get this data from PG ?...
0
by: hoenes1 | last post by:
How can I determine whether a download has been cancelled by the client? I'm sending the file from an aspx page in chunks of 4K. When the user presses "Cancel" in his download dialog, the next call...
3
by: Otavio Macedo | last post by:
Hi, I am working with MySQL 4.1 and I got a table with a point field. I need to do an "offset" in all the points, that is, adding some deltaX to the X coordinate and a deltaY to the Y...
6
by: magix | last post by:
Hi, when I read entries in file i.e text file, how can I determine the first line and the last line ? I know the first line of entry can be filtered using counter, but how about the last line...
158
by: jty0734 | last post by:
i don't know what input size of string is. so i can't gets inputsize before malloc function. i want determine the size of malloc without get inputsize in advance. how to deal with it?
36
by: James Harris | last post by:
Initial issue: read in an arbitrary-length piece of text. Perceived issue: handle variable-length data The code below is a suggestion for implementing a variable length buffer that could be used...
8
by: Thomas Mlynarczyk | last post by:
Hello, I want to split a given string into tokens which are defined by regexes: // example tokens - a bit more complex in real $tokens = array( 'NUMBER' ='~^\d+~', 'NAME' ='~^+~', 'ANY' ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.