mIRC Home    About    Download    Register    News    Help

Print Thread
#16423 22/03/03 01:42 PM
Joined: Dec 2002
Posts: 32
J
Jaakko Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Dec 2002
Posts: 32
Hello,

We know a starting point for a line, the direction the line goes and the length of line. How can we calculate the end point for it ?

Thanks in advance wink



am a big noob
#16424 22/03/03 07:17 PM
Joined: Mar 2003
Posts: 2
M
Bowl of petunias
Offline
Bowl of petunias
M
Joined: Mar 2003
Posts: 2
That can be solved by using the mIRC $cos and $sin functions. But, $cos and $sin require the value to be in radians, not degrees...

You can convert degree values to radians by multiplying the degrees by 0.017453 (which is pi / 180).

Say that %x1 and %y1 are the starting co-ordinates, %angle is the line's angle in degrees, %length is the line length... I'll use %x2 and %y2 as the ending co-ordinates:

set %x2 $calc(%x1 + %length * $sin(%angle * 0.017453))
set %y2 $calc(%y1 + %length * $cos(%angle * 0.017453))

#16425 22/03/03 10:13 PM
Joined: Mar 2003
Posts: 2
M
Bowl of petunias
Offline
Bowl of petunias
M
Joined: Mar 2003
Posts: 2
Sorry....I forgot the second $calc, and the negative sign.... replace the above with:
Code:
set %x2 $calc(%x1 + %length * $sin($calc(%angle * 0.017453)))
set %y2 $calc(%y1 + %length * $cos($calc(%angle * -0.017453)))


Also, I forgot to say: this assumes that an Angle of 0 degrees is due North.

#16426 22/03/03 11:11 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Both $sin and $cos have .deg properties which allow you to specify the angle in degrees instead of radians.


Spelling mistakes, grammatical errors, and stupid comments are intentional.

Link Copied to Clipboard