Re: Fw: Distance between 2 points
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Oct 01, 1998
- 673 views
>if you cannot, i suggest we leave it with 2d/3d. Well, at least time (4D) is a nice dimension to include. Distance is usually not really *that* important. Its also, how many time you have to get there ANd I think, time as 4th (or actually as first) dimension is pretty accepted, after that it becomes even more speculative.. (maybe, within a game, multiple ways a game could go, an enemy moving forward in some dimension, whereby he responds differently to things. >>However you can easily calculate distance of two >>points defined in 5 dimensions. >>And in one, is no problem also. Its just pos (a -b) >*distance*, yes. *angle*, no. Angle, either 0 or 180 for 1D. Is it moving forward or backward ? This would make it for 1D equal to: { compare (a,b) * (b - a), 180 + compare (a, b) * 180 } Or: { pos (a-b), (pos (a-b) = a - b) * 180 } Hmm, im on a roll, I feel. >so i left out the definition of FindDistanceAngle >for 1d, since it doesnt describe a right-triangle. What do right-triangles have to do with this ? In practicle theory 12323123^0 = 0, however consistency (and much smarter people as well make us use 12312329^0 = 1 However, real logic applied on this example (a power of zero) would give zero. Same goes for the distance and angle in the 1st dimension. You cannot really set the angle in practicle logic, but if you are consistent, you can. It still has a choice of direction, and therefor an angle of direction >>Could we get angles to work in any number of dimensions. >>In theory, giving 2 dimensions, you will get {distance,angle} >>Giving 3 dimensions should give you {distanze,xyangle,zangle} >>And with 4 dimensions we should get >> {distanze,xyangle,zangle,more_angles} >define more_angles, as per above??? >> Oh yes, Hawke, I forgot all about that. >'tis ok :) you've corrected me, politely, many times >when i fergot sumfin... i call 'em 'brainfarts'. :) Good name, smelly though. >ummmmm what should we do if adj is 0? >if it's zero, theta is *not* zero, in theory, >theta is *undefined*, is it not? :> Angle would be 0 or 180 wouldnt it be ? Well, here is my new relation (between two points) function: 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, 1.5708} -- Any1 wants to replace 1.5708 with something more precize ? end if end if a = a - b angles = {arctan(a[1]/a[2])} b = a * a dist = b[1] for index = 2 to length(a) do dist = dist + b[index] angles = append(angles, arctan(sqrt(dist), b[index]) end for return prepend(angles, sqrt(dist)) end function -- Voila (wow je parle francais! Or not.. haha..oh well .. ) Have fun all, Ralf