Calculating new coordinates based on current position, bearing and speed
Hi
I'm writing a program that needs to calculate a new set of coordinates based on the current position, the directional bearing and the speed of movement. The map is simply a flat 2D representation and therefore the Earth's curving axis does not need to be taken into account. I've searched through Google, but I can only find information on achieving this using lat/long on the Earth's 3D surface (which is a different representation and thus problem). Does anybody have any idea on what the equation is to achieve this? Thanks Cotun 
Check out Mr Pythagoras' famous idea

Quote:
cartesian coordinates polar coordinates into your favorite WEB search engine and reading the Wiki articles. 
Quote:
a = (angle in degrees) × Pi / 180Normally we define zero angle as towards the positive x axis, increasing towards the positive y axis. If at time t=0 you are at (x(0), y(0)), bearing a and velocity v, then you can calculate the position as a function of time t using x(t) = x(0) + t v cos aAs long as your units for x, y, v and t match ([x] = [y] = [t v]), and the units are uniform over the entire map, you can use any units you wish. 
Thanks to all of you, particularly Nominal Animal for providing the easytounderstand reference on the equation. It took me only minutes to implement this into my program and I do appreciate the effort you took.

Quote:

Because I implemented and tested the provided equation on a spreadsheet first. It provides exactly what I needed and works within expected boundaries.

Quote:
Sergei, do you realize how much math you need to actually know and understand to derive the equation? Cotun is obviously unfamiliar with this. Just because you (and I, I admit) think that this is something every programmer should know, does not make it so. Most of the links you show point to this familiar equation of motion, using vector notation: x(t) = x(0) + v t + 1/2 a t^2First, you need to understand vector notation, and that the above is actually equivalent to x(t) = x(0) + v_x t + 1/2 a_x t^2Then you need to realize that because the motion in this case is at constant velocity, the acceleration is zero: x(t) = x(0) + v_x tFinally, you must be able to convert the bearing from polar coordinates to cartesian coordinates, i.e. v_x = v cos bwhere "total" velocity is v, and bearing b is in radians counterclockwise from positive x axis. Then, and only then, you can arrive at the final equation, x(t) = x(0) + v t cos bMath is unlike programming in that the end result is almost always easier to understand and apply than the method of arriving at it. In fact, usually the method of finding a solution requires not only experience, but creative leaps (or tedious hours of trial and error). Therefore, I believe, we should point those with math problems towards the equations themselves, and perhaps explain (with references) why and how they work. After all, this is not a theoretical math forum; all math problems we're likely to see are "applied" math. Don't you agree? 
Quote:

Quote:
If a programmer is a domain programmer, he/she should know the domain. "Know" means being able to prove what is provable FWIW, looking up info on Digital Fourier Transform in Wiki I disagreed ((slightly) with their formula for Hanning window (the disagreement is N <> N  1 and for large Ns is insignificant, but still). I was once looking into somebody else's FFT code and did find a significant bug in windowing  significant because quite audible. And mathematically it was a bug  much more significant than the above N <> N  1. More on DFT  other pitfalls are scaled/unscaled and complex exponent imaginary part sign. 
Quote:
I.e. suppose I tell you that linear function is y(x) = k * x + b + sin(x * pi) and tell you to check it for x = 0, 1, 2, 3 ...  though the above function is wrong, it will work for the suggested set of test points exactly as the correct y(x) = k * x + b one. I think in a Niklaus Wirth's book I once read: "Testing never proves absence of bugs, it can only prove their presence"  I don't claim it's the exact quote, but the sense was definitely like this. 
Quote:
Quote:

Quote:
Quote:
We all depend on things done by others on a daily basis and often build upon those too. You should be able to prove that the water you drink is safe before you actually do, but few people would do that. Most people wouldn't know how to start doing that, just as I don't have presently have the mathematical basis to do what you expected me to do. I realise of course that you were talking generically about being able to understand what you are implementing, but I think you are being too theoretical and thus harsh when you look at the realworld application. 
This thread reminded me of a joke I read on facebook:
Quote:

Quote:

All times are GMT 5. The time now is 06:48 AM. 