How to Calculate Destination Coordinates in a Trig Graphing Program?

In summary, the conversation discusses a problem in which the user needs to find the destination grid coordinates based on a given angle and distance. The solution involves using trigonometry and approximations using series. The conversation also suggests trying out different angles and lengths to determine the accuracy needed for the solution.
  • #1
Slinger1010
1
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
  • #2
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 [itex](x_1, y_1)[/itex]. 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 [tex]\sin A = \frac{x_1}{r} \to x_1 = r \sin A[/tex] and [tex]\cos A = \frac{y_1}{r} \to y_1 = r \cos A[/tex].

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;

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

[tex] n! = 1\cdot 2 \cdot 3 \cdot 4 \cdot 5 ...\cdot (n-1) \cdot n[/tex] (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 [tex] \frac{A\pi}{180}[/tex] 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 =]
 
  • #3
nie

Hi Ronnie,

Thank you for reaching out for help with your trig graphing problem. It sounds like you are trying to create a program that will calculate the destination coordinates based on the user's input of direction and distance. This can definitely be a tricky task, but I'm happy to offer some guidance.

First, let's review some basic trigonometry principles that will be helpful in solving this problem. In a right triangle, the sine, cosine, and tangent functions are defined as follows:

- Sine (sin): opposite/hypotenuse
- Cosine (cos): adjacent/hypotenuse
- Tangent (tan): opposite/adjacent

In your case, the user will input the direction in degrees, which we can convert to radians for easier calculation. Remember that 360 degrees is equivalent to 2π radians. So, if the user inputs a direction of 90 degrees, that would be equivalent to π/2 radians.

Next, we need to consider the distance the user wants to travel. This will be the length of the hypotenuse in our right triangle. We can use the Pythagorean theorem to calculate the length of the other two sides (x and y coordinates). The formula is a² + b² = c², where a and b are the lengths of the two shorter sides (x and y coordinates) and c is the length of the hypotenuse (distance).

With this information, we can create a formula to calculate the destination coordinates:

- x = distance * cos(direction in radians)
- y = distance * sin(direction in radians)

Remember to round the coordinates to the nearest whole number, as you mentioned that rounding is acceptable.

I hope this helps you with your program. If you need any further clarification or assistance, please don't hesitate to ask. Best of luck!
 

Related to How to Calculate Destination Coordinates in a Trig Graphing Program?

What is a Trig graphing problem?

A Trig graphing problem is a type of mathematical problem that involves graphing trigonometric functions. These functions involve ratios of sides of a right triangle and are commonly used in geometry and physics.

What are the basic trigonometric functions?

The basic trigonometric functions are sine, cosine, and tangent. These functions represent the ratios of the sides of a right triangle, specifically the opposite, adjacent, and hypotenuse sides, respectively.

How do I graph a trigonometric function?

To graph a trigonometric function, you will first need to plot points on a coordinate plane using the values of the function. Then, connect the points with a smooth curve to create the graph. You may also need to adjust the scale of the axes to accurately represent the function.

What are the key properties of trigonometric graphs?

The key properties of trigonometric graphs include the period, amplitude, and phase shift. The period is the length of one complete cycle of the graph, the amplitude is the maximum distance from the x-axis to the curve, and the phase shift is the horizontal translation of the graph.

What are some common applications of trigonometry?

Trigonometry has many practical applications including navigation, surveying, engineering, and astronomy. It is also used in music and art to create patterns and designs. Additionally, trigonometric functions are used in physics to model periodic motion and in calculus to solve differential equations.

Similar threads

Replies
7
Views
2K
  • Introductory Physics Homework Help
Replies
8
Views
616
  • Differential Geometry
Replies
3
Views
1K
Replies
7
Views
4K
Replies
20
Views
3K
Replies
5
Views
2K
  • Programming and Computer Science
Replies
4
Views
667
Replies
5
Views
2K
  • Calculus and Beyond Homework Help
Replies
7
Views
713
Back
Top