Comments
Join Hawkee
|
Login
Search
in
Code Snippets
Products
Reviews
Forum
Home
Platforms
Cold Fusion
CSS
Javascript
mIRC
mySQL
.NET
OpenSocial
Perl
PHP
Python
Ruby / Rails
TCL
Snippets
Cold Fusion (1)
CSS (2)
Javascript (4)
mIRC (3,543)
mySQL (1)
.NET (5)
OpenSocial (1)
Perl (7)
PHP (126)
Python (1)
Ruby / Rails (6)
TCL (16)
Products
Computers (12,445)
Electronics (7,754)
Software (1,209)
Video Games (4,321)
Reviews
Computers (5,892)
Electronics (14,528)
Software (2,556)
Video Games (7,035)
Comments
Forum
username
password
auto login
Home
>
Code Snippets
>
BlueThen's Snippets
>
mIRC
$GetAngle
Please
Register
to submit score.
Average Score
7.3
Scores Submitted
3
Date Added
May 06, 2008
Last Updated
May 10, 2008
Tags
angle
angles
bluethen
etc
getangle
trig
trigonometry
Introduction
$getangle is just what it sounds like, it retrieves the angle of any two points using triangles and trigonometry.
Updates:
Fixed an error where the angle is sometimes off by 20 degrees.
Grab the Code
;$GetAngle 1.1 ;made by BlueThen ;It'll return the angle of any 2 points. ;Syntax: $getangle(P1x,P1y,P2x,P2y) alias getangle { %p1.x = $1 | %p1.y = $2 | %p2.x = $3 | %p2.y = $4 | %p3.x = %p2.x | %p3.y = %p1.y %opposite = $sqrt($calc((%p2.x - %p3.x)^2 + (%p2.y - %p3.y)^2)) %hypotenuse = $sqrt($calc((%p2.x - %p1.x)^2 + (%p2.y - %p1.y)^2)) | %angle = $asin($calc( %opposite / %hypotenuse )).deg if (%p1.y < %p2.y) %angle = $calc(360 - %angle) | if ((%p1.x > %p2.x) && (%p1.y > %p2.y)) %angle = $calc(180 - %angle) elseif ((%p1.x > %p2.x) && (%p1.y < %p2.y)) %angle = $calc(180 +(360 - %angle)) | return $calc(360 - %angle) }
Comments
(7)
RSS
Go to Bottom
BlueThen
Comments:
150
Posted on
May 6, 2008 4:18 pm
Aw, someone rated it a 4.
Sorry it's not a cool picwin or anything, but it honestly took me hours to find this out.
^Neptune
Comments:
129
Posted on
May 6, 2008 4:22 pm
This could be really useful for picwin makers. Good job. Try making the variables local (var %variable), it's nice to stop the variables bit clogging up. :)
BlueThen
Comments:
150
Posted on
May 6, 2008 4:31 pm
Oh, I forgot. This was originally was an experimentation, but someone wanted it.
jonesy44
Comments:
364
Posted on
May 6, 2008 4:32 pm
Good stuff, i'll no doubt need this for my next picwin .. when i try it haha !
But it'll be pretty hard i guess.
Promise ya don't steal it, but i think i'll need a simple one of newton's laws to work it ;D
Noutrious
Comments:
316
Posted on
May 7, 2008 2:49 pm
Respecting this not only because of the good coding, but of the mathematical skills too - i couldn't figure this out actually.
BlueThen
Comments:
150
Posted on
May 10, 2008 2:23 pm
Updated. I've been getting some complaints saying that it was off by 20 or so degrees every now and then. So after about a hour of looking, I finally found out that the length wasn't accurate...
So now it's fixed. ;)
jonesy44
Comments:
364
Posted on
May 10, 2008 5:09 pm
Nice one, never got round to using this ident yet :P
Enter comment here..
Please
Register
or
Login
to start posting comments.
BlueThen
Last seen:
May 11, 2008
Profile
|
Website
Friends
(4)
Snippets
(29)
Images
(31)
Comments Received
(349)
Comments Submitted
(150)
Forum Posts
(68)
My Snippet Tags
3d
8ball
1337
angle
angles
anti
antirepeat
antispam
ball
big
blend
bluethen
bubbles
button
calc
calculator
chart
circle
click
clock
collision
config
configurable
cube
custom
dialog
dots
dumb
engine
etc
eyes
field
flashlight
funny
game
generator
getangle
grav
gravity
idiot
leet
light
lines
mirc
mouse
neon
nicklist
pertty
phys
physic
physics
pi
picwin
pie
puke
repeat
script
sex
simple
small
snake
snippet
spam
spin
spinning
stakes
star
starfield
stars
string
swirl
switch
test
text
time
timer
translator
trig
trigonometry
type
typing
vortex
Contact
Add to Friends
Send Private Message
Friends (4)
^Neptune
jonesy44
View All