Sign in to follow this  
Followers 0
Kyler Carlson

Math help Please

7 posts in this topic

I really am not having luck searching google so i think i'll ask you cuys. Whats the formula to fin the angle that 3 points make... like say i have point A, B, and C somewhere on my desktop... how can i determine the angles of them? thanks in advance.

Share this post


Link to post
Share on other sites



I really am not having luck searching google so i think i'll ask you cuys. Whats the formula to fin the angle that 3 points make... like say i have point A, B, and C somewhere on my desktop... how can i determine the angles of them? thanks in advance.

Whipped up this UDF, i think it works... but its been a while since i tried trig..

Uses the '_Distance' UDF from SolidSnake

Func _Angle($xa, $ya, $xb, $yb, $xc, $yc, $angle = "B")
    $SideA = _Distance($xc, $yc, $xb, $yb)
    $SideC = _Distance($xa, $ya, $xb, $yb)
    $SideB = _Distance($xc, $yc, $xb, $yb)
    Switch $angle
        Case "B"
            Return ACos(($SideA^2 + $SideC^2 - $SideB^2)/(2*$SideA*$SideC))
        Case "A"
            Return ACos(($SideB^2 + $SideC^2 - $SideA^2)/(2*$SideB*$SideC))
        Case "C"
            Return ACos(($SideA^2 + $SideB^2 - $SideC^2)/(2*$SideA*$SideB))
    EndSwitch
EndFunc

Func _Distance($iX1, $iY1, $iX2, $iY2)
    Return Sqrt(($iX1 - $iX2) ^ 2 + ($iY1 - $iY2) ^ 2)
EndFunc

Share this post


Link to post
Share on other sites

not sure how to do it code-wise, but if its a right angle, pothagorean's theorum... remember a triangle has 180 degrees total... otherwise...

idk so gl lol

I Thought the pythogorean theorum was for finding the length of the hypotenuse?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Pythagorean Theorem

http://www.cut-the-knot.org/pythagoras/index.shtml

Let's build up squares on the sides of a right triangle. Pythagoras' Theorem then claims that the sum of (the areas of) two small squares equals (the area of) the big one.

In algebraic terms, a2 + b2 = c2 where c is the hypotenuse while a and b are the legs of the triangle.

:whistle: so yea a simple check to make sure its a true triangle would be

If  $SideA + $SideB + $SideC <> "180"  Then  Exit
MsgBox(0, "Error", "Their was an error in the calculation")
Edited by 4gotn1

Share this post


Link to post
Share on other sites

wasn't $sideA $SideB and $SideC distances ? it's the angles that should be 180.

if no angle in the triangle is 90 degrees you can't use pythagoras theorem.


> there are 10 types of people in the world, those who understand binary and those who don't.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0