Re: Distance and Angles in Multiple Dimensions

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

Ralf Nieuwenhuijsen wrote:
> function relat (object a, object b)
>     a = a - b
>     -- Not the fastest approuch though:
>     a = a * ((a < 0 * -1) + (a > 0))
ummmm.... i don't really think the line above is quite
the ticket... you're trying to make sure there are no
negative values... but you *want* the signs... arctan()
depends on sign(+-) to determine which of 2 quadrants
your vector is running.  this will return only one
quadrant's worth of vectors...

when I wrote the any angle line drawing routines for
the truecolor.e library, i made sure that startX was
less than endX
  (since we are dealing with CRT coordinates, 0,0=upleft)
and then I *kept* the sign for the Y values.
this will return a line that is properly going up or down...

i've found it simplest to just do a=b-a, and in the arctan
part, make it arctan(opposite/absolute(adjacent))....

>This will work, but if any one has a more idealistic approuch to
>handle the division by zero thingie ?
>     a = a + (a = 0) * 0.000000000000000001
>     angles={arctan(a[2]/a[1])}
how about simply:
   if a[1]=0 then angles={0}
   else angles={arctan(a[2]/abs(a[1])}
   end if
this will keep your precision for *large* universes/coordinate
systems (as when they may be using viewport.e???)

naturally, same as above goes here as well...

justa my thoughts...--Hawke'

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

Search



Quick Links

User menu

Not signed in.

Misc Menu