How to Calculate Destination Coordinates in a Trig Graphing Program?

  • Thread starter Thread starter Slinger1010
  • Start date Start date
  • Tags Tags
    Graphing Trig
Slinger1010
Messages
1
Reaction score
0
I'm writing a program in VB but since math isn't my strongest suit I'm having a little trouble figuring out the equation for this:
I have a grid 100 x 100.

The user will input the direction in deg and the distance to travel. I need to get the destination grid x and Y.
0 Deg is facing up.

I don't mind if there is a little bit of error, in fact I want it. Rounding is acceptable.

Any help is appreciated, if you need more info just ask please.

Ron
 
Mathematics news on Phys.org
Welcome to PhysicsForums Slinger1010 !

If I have interpreted your problem correct, from a given angle and length, you want to find the x-y co ordinates the line stops on?

If that is the problem, I can help =] Ok I want you to try 4 separate x-y axis on a piece of paper. On the first one, draw some straight line with length r (distance to travel) and some angle between 0 and 90 in degrees (the first quadrant). Label the angle A. We define to co-ordinate this line A degrees from facing straight up and r units from the origin to have Cartesian Co-ordinates (x_1, y_1). Now, put your pen on that point, and draw a horizontal line until you hit the y-axis. Y

What you have now is a right angled triangle, where you know the lengths of all sides =] The side adjacent to A is y_1, the side opposite A is x_1, and the hypotenuse is r. Using elementary trig, we see that \sin A = \frac{x_1}{r} \to x_1 = r \sin A and \cos A = \frac{y_1}{r} \to y_1 = r \cos A.

Now, with the other 3 axis you drew, draw other lines with length r and angle A, except make them in the 2nd, 3rd and 4th quadrants respectively. Then find the right angled triangle in each of them like I just did. To see if your on the right track, the second quadrant should have the same solutions except (180 -A) replacing A.

As for wanting some error, there are well known series that represent the Cosine and Sine functions;

\sin x = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} ...
\cos x = 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} ...

n! = 1\cdot 2 \cdot 3 \cdot 4 \cdot 5 ...\cdot (n-1) \cdot n (The product of the positive integers upto n.

The thing is, all of those series only work when x is in radians, not degrees. However if we convert, we work out that A degrees is \frac{A\pi}{180} radians, so we put that in everywhere in replacement of x.

Each of those series have an infinite amount of terms, taking all of them gives exactly cosine x and sine x, but taking the first few gives good approximations. Using more terms gives better approximations, however the approximations are much better for small numbers than they are for big numbers. For example to get 5 digits of accuracy of Sin x when x is 10 degrees, you might only need to take the first 3 terms, but to get the same accuracy when x is 300 degrees, it might take 6 or something.

Play around with it on your calculator, see how accurate you want it to be =]
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
Thread 'Imaginary Pythagorus'
I posted this in the Lame Math thread, but it's got me thinking. Is there any validity to this? Or is it really just a mathematical trick? Naively, I see that i2 + plus 12 does equal zero2. But does this have a meaning? I know one can treat the imaginary number line as just another axis like the reals, but does that mean this does represent a triangle in the complex plane with a hypotenuse of length zero? Ibix offered a rendering of the diagram using what I assume is matrix* notation...
Back
Top