What I am trying to do is draw a line from a central point out to the x and y coordinates of the mouse, and the line has to be a certain length. In other words, I want the line to be pointing at the mouse all the time from a central point, but it cannot be longer than a set length (So I can't just have it draw a line from the central point to the mouse coords).
Ex)
----------------------
C
/
/
/
E
.
.
.
M
------------------
KEY:
C - Central pivot point (beginning of the line)
E - end of line
/ - line (the length of the line is the distance between # and @)
. - imaginary line
M - Mouse location
So far, to draw a line that is a certain length, I would do something like this:
xfinalpos = xbeginposition + sin(20*(PI/180))*linelength;
yfinalpos = ybeginposition + cos(20*(PI/180))*linelength;
That works because I already know the angle -> 20. But when I move the mouse around the central point, I don't know the angle.
I think I need to use arcsin, arccos, or arctan, but I am not sure which one, or how to use them. Can anyone help me do this?
Edited by - IronFist on July 28, 2001 2:25:42 AM