Skip to main content
gamedev.net
🔒 Locked

i need some help

Started by pyro1245 5 replies 350+ views
Original Post
pyro1245
pyro1245
does anyone know how to find the slope of a line given the angle, starting point, and length? #include <leet>
Erunama
Erunama
This is off the top of my head:

Point A = (Ax, Ay) <-- this is the starting point (which you say is given)

Point B = (Bx, By)
= (Ax + length*cos(angle),Ay + length*sin(angle))

Slope = (By - Ay) / (Bx - Ax)

Hope that is correct.


EDIT: Added code tags to preserve formatting

[edited by - Erunama on May 31, 2002 5:07:20 PM]
pyro1245
pyro1245
thanks a lot.

ive been trying to figure out a way to do that for a long time

#include <leet>
pyro1245
pyro1245
ok, after further testing of it, there is a problem.

the only angle ot really works on is 0

can you please see if there is a way to fix this

thanks
IndirectX
IndirectX
If you have the angle, then the slope is the arctangent of the angle.
---visit #directxdev on afternet <- not just for directx, despite the name
Zaphos
Zaphos
Yes, double slope = atan(angle);!
The question is not "why a talking monkey," but rather, "why not a talking monkey." -Monkey Island 4
Erunama
Erunama
pyro: What form are you storing your angles in, degrees or radians? If you are using degrees, then of course you will be having problems because trig functions use radian measure.

To convert, just multiply the degree measurement by 180/PI

Here''s a little real code/pseudo-code:


  
#define PI 3.14159
...
angle = angle*180/PI
sin(angle)


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.