Post Reply 
What is the best way to store coordinates
12-16-2013, 06:45 AM
Post: #2
RE: What is the best way to store coordinates
Hello,

points are 2 real numbers (assuming 3D)... This gives you a couple of possibility for storage:
- 2 numbers
- in a list
- in a matrice (as a single line, as a single column, as 2 elements side by side with other elements)
- 1 complex number
- in a list
- in a matrice (in a vector or a real matrice?)
- other solutions are possible (such as a string), but are unlikely to be the best solution...

The storage that you will use will depend on what you are trying to do whith the object and which build in functions are available to handle them.
Are the points that you are going to store part of a point grid? if yes, then a matrix might be a good solution. If on the onctrary, you have an arbitrary number of points, a list might be more adapted.

A matrice tend to be faster than a list and takes less memory (because 1 matrice is just 1 block of memory with all the data in it, 8 bytes per numbers). while a list is an array of pointers on objects (one per number), yeilding much more memory used and memory allocations (which are slow)...

remember, list processing is your friend! for example, assuming that you are storing points as complex numbers in a list. a rotation by 90° is just a multiplicaiton of the list of complex nubmers by (0, 1) as in:
local l:= { My List of points };
l:= l*(0,1); // rotates all points by 90°

Cyrille
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: What is the best way to store coordinates - cyrille de brébisson - 12-16-2013 06:45 AM



User(s) browsing this thread: 1 Guest(s)