Computer Science Canada

Angles?

Author:  gg900 [ Tue Apr 01, 2008 11:45 am ]
Post subject:  Angles?

how would i make a bullet or something travel at an angle? or like a line be draw at an angle, how can i change it later? or make a line segment travel in a line.

Author:  Tony [ Tue Apr 01, 2008 12:24 pm ]
Post subject:  RE:Angles?

do you know how to draw a line at a 90 degree angle? That is, vertically straight.

Author:  A.J [ Tue Apr 01, 2008 5:53 pm ]
Post subject:  Re: Angles?

in the equation of a line y= mx + b where m = the slope, the tan of the angle formed by that line and the x-axis is equal to the slope of that line!

for example, in the line y = x, the slope = 1 so the angle formed with the x-axis is arctan(1) = 45 degrees.

if you want to calculate the angle formed by the bottom-left of the screen and a point P(x,y), its just arctan(y/x) (same as the slope:rise over run)

this can be a little confusing if you haven't learned trigonometric functions yet.

sry but I'm in a hurry,
A.J

Author:  gg900 [ Thu Apr 03, 2008 6:45 pm ]
Post subject:  RE:Angles?

alright, i half get it I can do slope, but i dont know how I would increase the x and y every step. I havent learned trig yet either thanks.

Author:  OneOffDriveByPoster [ Thu Apr 03, 2008 9:05 pm ]
Post subject:  Re: Angles?

I swear there are many posts about this already. In any case, no slope and no trig is required.

Point p
Point q

Parametric form of the line between p and q:
r(s) = p + s(q - p)

If you want to move in a straight line from point p to point q, then draw your object at r(s) for
some values of s from 0 to 1 (inclusive). If the equation is confusing, then consider the midpoint
between p and q--it is r(0.5).

If you have p, some distance to travel (length) and an angle (theta) instead, then
q = p + length*( cos(theta), sin(theta) ).

Okay, so there was trig...

Author:  andrew. [ Fri Apr 04, 2008 9:04 pm ]
Post subject:  Re: RE:Angles?

gg900 @ Thu Apr 03, 2008 6:45 pm wrote:
I havent learned trig yet either thanks.


That's the problem. Do a quick Google search. Trig is easy and doesn't take a while to learn. I learned it in 5 minutes. Once you learn that, all your angle problems are solved.


: