Re: Fw: Distance between 2 points
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Oct 01, 1998
- 680 views
[Code] Pretty neat, Hawke. I didnt mess with the angle, cuz I was wondering how I would do that for multiple dimensions. 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) 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} And Hawke, I started to talk about sum () Lets try an optimization thread on sum () Here is the beginning function: function sum (object x) atom ret if atom(x) return x elsis not length(x) then return 0 end if ret = sum (x[1]) for index = 2 to length(x) do ret = ret + sum(x[index]) end for return ret end function [Code snipped] Oh yes, Hawke, I forgot all about that. You're right, I should have used the a * a approuch. Oh well, I think it will be the fastest. The sum function above on the otherhand is just a simple one, it can be much faster I think. Ralf