What is the best way to store coordinates

12162013, 05:57 AM
Post: #1




What is the best way to store coordinates
I would like to write some coordinate geometry programs but don't know where to start. I would like to start with a simple program to store and recall points. I would like to be able to store point number, northing, easting, elevation, and a aphanumeric code. Would it be better to store these as vectors or coordinates? Is it better to use a list or a matrix or is there something I'm overlooking.
Thanks CD Dodds 

12162013, 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 

12162013, 10:54 AM
(This post was last modified: 12162013 10:55 AM by ArielPalazzesi.)
Post: #3




RE: What is the best way to store coordinates  
12162013, 03:04 PM
(This post was last modified: 12162013 03:06 PM by Tim Wessman.)
Post: #4




RE: What is the best way to store coordinates
Well, this is bringing back memories. :)
If you really would like to keep them grouped and since you are dealing with real numbers, I'd recommend doing a { #PN, [ N,E,EL], " " } type of structure. Note that there are not really 2d/3d vectors, but I believe you'll find grouping them like such will prove convenient. The first number I'd keep as an integer just for clarity's sake, but sticking it into the vector would reduce the size slightly. Compared with the 48 series, lists are going to be VERY fast because sizing information is encoded in the list and you don't have to scan everything to know the list size or get to the next object. Alternatively, you could have 1 list of point numbers, 1 list of your vectored N,E,EL, and then 1 list for your codes. This would definitely be the fastest as you can do quicker searches for the PN or matching codes, but you have to be certain nothing can get out of sync else everything is messed up. TW Although I work for HP, the views and opinions I post here are my own. 

12172013, 09:41 AM
Post: #5




RE: What is the best way to store coordinates
Hello,
(12162013 03:04 PM)Tim Wessman Wrote: I'd recommend doing a { #PN, [ N,E,EL], " " } This structure might work for you, but it has 1 drawback you can not use list processing on it. if you were to use something around the lines of l:={ [x,y,z],[x,y,z]...} then you would be able to do something like: l:=l*rotation_matrice and stuff like that... but if you need to keep meta data on points (such as numbers, names....) you could keep them in a separate list somewhere else... cyrille 

12172013, 03:30 PM
Post: #6




RE: What is the best way to store coordinates
Quote:you can not use list processing on it. Yup, except that will #never# be done for any surveying related calculation except the possibility of least squares regression. TW Although I work for HP, the views and opinions I post here are my own. 

« Next Oldest  Next Newest »

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