473,796 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4682
fr********@yaho o.com (some one) wrote in
news:54******** *************** **@posting.goog le.com:
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.programmin g instead?

--
- Mark ->
--
Nov 14 '05 #2
some one <fr********@yah oo.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.hel sinki.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
3052
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
2565
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 the name of the 'encoded' output file, and the final filename is an offset file. On a character by character basis, the program needs to look at the first character of the source file and offset it by the first character in the offset file. The...
0
5800
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 ? SELECT ... ; ----> returns 100,000 rows
0
1120
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 of Response.Flush() hangs and resets my Session Object after about a minute. The Response.IsClientConnected property is still true after the user pressed "Cancel". Is there a workaround for this problem? The Code is: // fs --> FileStream //...
3
2157
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 coordinate. How can I do this using the update statement?
6
5789
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 of entry in EOF while loop ? while (! file.eof() ) { ....
158
6177
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
3820
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 to read text or handle arrays of arbitrary length. I don't have the expertise in C of many folks here so I feel like I'm offering a small furry animal for sacrifice to a big armour plated one... but will offer it anyway. Please do suggest...
8
4002
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' ='~^.~' ); // make sure there is always a match
0
9535
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10467
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10244
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10201
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9061
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4130
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.