Re: Distance and Angles in Multiple Dimensions
I stand completely corrected, Hawke.
For me the word speculate is pretty much how I made the function.
And indeed a lot of brainfarts. Oh well, Im not accurate enough for match.
Im used to Euphoria telling me I did something wrong, and what Im doing
wrong. Esspecially during math tests, I need to remember, that my result
isnt a prototype or something, oh well, we figured it out now, havent' we ?
Ive removed the '>' and stuff, so people can easily cut & paste, if they
ever wanne make some science fiction game
function relat (object a, object b)
sequence angles
atom dist
if atom (a) and atom(b) then
if a>=b then return {a-b,0} -- angles start at zero, end of
discussion
else return {b-a,PI}
end if
end if
a = a - b
-- Not the fastest approuch though:
a = a * ((a < 0 * -1) + (a > 0))
b = a * a
-- Jiri or any other math magician wanne help out here ?
-- This will work, but if any one has a more idealistic approuch to
handle the
-- division by zero thingie ?
-- Or do I need to look this up in some old math book ?
a = a + (a = 0) * 0.000000000000000001
angles={arctan(a[2]/a[1])}
dist = b[1]
for index = 2 to length(a) do
dist = dist + b[index]
angles=append(angles,arctan(a[index],sqrt(dist)))
end for
return {sqrt(dist),angles}
end function
|
Not Categorized, Please Help
|
|