Jump to content

Recommended Posts

Posted

or you can use this function to find the hypotenuse of a triangle

you need to know 2 sides and for the side that you dont know just put a question mark like this "?" with parenthesis

Func hypotenuse($sidea,$sideb,$sidec)
    Select
case $sideA = "?"
$b2 = $sideB * $sideb
$c2 = $sidec * $sidec
$answer = $c2 - $b2
$answer1 = Sqrt($answer)
Return $answer1
case $sideb = "?"
$a2 = $sidea * $sidea
$c2 = $sidec * $sidec
$answer = $c2 - $a2
$answer1 = Sqrt($answer)
Return $answer1
case $sidec = "?"
    $b2 = $sideB * $sideb
$a2 = $sidea * $sidea
$answer1 = $a2 + $b2
$answer2 = Sqrt($answer1)
Return $answer2
EndSelect
EndFunc

example : msgbox("The hypotenuse of a triangle with sides of 3 and 5","The hypotenuse is: " & hypotenuse(3,4,"?")

will return 5

Posted

as Wus already said, just add the 3rd dimension to the function and your done....

done. ;)

I haven't done extensive testing though as I do not have 3d rendering software. Anyone care to test it out?

Func _Distance3D($iX1, $iY1, $iZ1, $iX2, $iY2, $iZ2)
    Return Sqrt(($iX1 - $iX2) ^ 2 + ($iY1 - $iY2) ^ 2 + ($iZ1 - $iZ2) ^ 2)
EndFunc  ;==>_Distance3D
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Posted

or you can use this function to find the hypotenuse of a triangle

you need to know 2 sides and for the side that you dont know just put a question mark like this "?" with parenthesis

Func hypotenuse($sidea,$sideb,$sidec)
    Select
case $sideA = "?"
$b2 = $sideB * $sideb
$c2 = $sidec * $sidec
$answer = $c2 - $b2
$answer1 = Sqrt($answer)
Return $answer1
case $sideb = "?"
$a2 = $sidea * $sidea
$c2 = $sidec * $sidec
$answer = $c2 - $a2
$answer1 = Sqrt($answer)
Return $answer1
case $sidec = "?"
    $b2 = $sideB * $sideb
$a2 = $sidea * $sidea
$answer1 = $a2 + $b2
$answer2 = Sqrt($answer1)
Return $answer2
EndSelect
EndFunc

example : msgbox("The hypotenuse of a triangle with sides of 3 and 5","The hypotenuse is: " & hypotenuse(3,4,"?")

will return 5

I couldve used this awhile back. ;)
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Posted

If anyone is interested in a 2d/3d project you could try coding up a convex hull algorithm. Uses alot of geometry and is a good application of vector products.

Its entirely possibly you already coded it up for your library though...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...