Re: Distance and Angles in Multiple Dimensions

new topic     » goto parent     » topic index » view thread      » older message » newer message

Ralf Nieuwenhuijsen wrote:
>Anyone (theoretically) disagrees,
>since we cant test it in practise ?
ummmm i think i might gotta :)

>-- Any1 wants to replace 1.5708 with something more precize ?
constant PI    =arctan(1)*4
constant HALFPI=PI/2

> 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}
>         else  return { b-a, HALFPI}
--btw, i'm debating if that's actually right...
--after all, when talking radians, it goes from
-- -pi/2 to pi/2, so 0degrees is -pi/2 and 180 is pi/2
--or if you make 0degrees = -pi/2 then 180 is PI and
--90 is pi/2.
--therefore, shouldnt the line read either:
-- 1>   if a>=b then return {a-b,-HALFPI}
--      else return {b-a,HALFPI}
-- OR
-- 2>   if a>=b then return {a-b,0}
--      else return {b-a,PI}
--or am i really thinking screwy here?

>         end if
>     end if
>     a = a - b
--we might want to make this a=b-a... i'm thinking we're
--going to get into having occassional upsidedownness...

>     b = a * a
>     a = a + (a = 0) * 0.000000000000000001    -- Precize enough ?
>     angles = {arctan(a[1]/a[2])}
--first actual oopsie :)
--let's make this angles={arctan(a[2]/a[1])}, shall we? :)

>     dist = b[1]
>     for index = 2 to length(a) do
>         dist = dist + b[index]
>         angles = append(angles, arctan(sqrt(dist), b[index])
--second oopsie :)
--how about:
--instead???
--wouldn't that be right?? :)
>     end for
>     return prepend(angles, sqrt(dist))
--why not simply: return {sqrt(dist),angles} ??
--saves a nonneeded function call, and i think it's
--a little easier to read... :) just my opine, mind you...
> end function

i'm purty sure of the corrections i made, but of course,
i'm not wholeheartedly sure :)

--Hawke'

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu