problem with lines. 
aca88 
Hi, i really need help with this one. i would appreciate if someone could help me solve this as it is a project i have to give on monday. here is an image i created
http://imageshack.us/photo/myimages/269/clay1boxesmesh.jpg/
i would like to know if i could draw a line that would start from a box that i would click and have as knots the boxes that would meet until it reaches the other box on the top of the tower. not in 2d (like a movement only on z axis) but in 3D. lets say every time that it needs a knot to choose the closest boxes or the boxes inside a given range. hope i make my point!
thank you
read 853 times 6/22/2011 11:16:30 PM (last edit: 6/22/2011 11:29:52 PM)

aca88 
if the image is not seen here is the linkhttp://imageshack.us/photo/myimages/193/clay1boxesmesh.jpg/
read 843 times 6/22/2011 11:20:17 PM (last edit: 6/22/2011 11:20:17 PM)

Nolan 
Take out the image tags to show the picture in the thread.
read 839 times 6/22/2011 11:22:49 PM (last edit: 6/22/2011 11:22:49 PM)

aca88 
oh, found it. but its really small
read 832 times 6/22/2011 11:27:27 PM (last edit: 6/22/2011 11:33:00 PM)

LionDebt 
direct image link ftw.
read 808 times 6/23/2011 12:16:59 AM (last edit: 6/23/2011 12:16:59 AM)

aca88 
right, thanx ;P
read 790 times 6/23/2011 1:09:54 AM (last edit: 6/23/2011 1:10:11 AM)

aca88 
Anyone ?
it is maybe a search algorithm. or even a GA. but it doesnt have to be that complicated. just few tricks should be ok (if there are any)
read 754 times 6/23/2011 9:25:40 AM (last edit: 6/23/2011 9:25:40 AM)

jareu 
im really confused. could you please describe what you want again in more lamen's terms?
He who says it cannot be done is interrupting the man doing it.
read 749 times 6/23/2011 10:35:44 AM (last edit: 6/23/2011 10:35:44 AM)

aca88 
sure. in the model you are seeing in the picture i would like to draw lines that would start from a box at the bottom and end to a box on the top of the tower (or maybe lower) . but i need the knots of the line to BE the boxes (lets say the .center) that interfere between the line's path.
http://imageshack.us/photo/myimages/96/lineknotsthroughboxes.jpg/
i pick the Starting Box and the box at the End and the algorithm finds the boxes in a vertical path by choosing wich boxes fits the best for the climbing path. it seems like a branching system or some kind of a genetic algorithm but if it can be done with approximation im ok with it.
in the image its done manually.
read 745 times 6/23/2011 11:08:25 AM (last edit: 6/23/2011 11:10:27 AM)

Garp 
A simple algorithm would be to go from bottom to top by all possible ways (picking one box per level) and retain the shortest path. Then build the spline from there.
 sort the boxes in an array using their z coord  split into one array per level (with some threshold on z, say 10% of a box height).  change the first and last array to hold only the first and last box.  go through all the paths using one box per level, each time computing the distance as you go, filling a bitarray with the subarrays' indices, comparing with previous distance and keeping the smallest.  use the resulting bitarray to retrieve the boxes and their centers.  build the spline.
It's a poor algorithm, performance wise, but it's simple enough to implement and since you don't have many boxes it should do.
read 731 times 6/23/2011 11:29:48 AM (last edit: 6/23/2011 11:31:57 AM)

aca88 
ok, i understood what youre saying but will def need help as i dont know anything about bitarrays . but i also think that maybe i dont need bit arrays.
lets say that i have the sorted array according to z. how do you implement the threshold?
read 722 times 6/23/2011 11:52:01 AM (last edit: 6/23/2011 11:52:01 AM)

Garp 
Look up bitarray in the reference.
This should help:
read 702 times 6/23/2011 1:04:48 PM (last edit: 6/26/2011 9:24:22 PM)

aca88 
oh, thats perfect, thanks a lot Garp for taking time to write it!
in your natural language , what do you mean ''change the first and last array to hold only the first and last box ?''
as i cas see now i have to select a box, locate its center inside the sorted_box_sets, and compare it among the other levels until the 2 centers (of the starting box and the target box) meet each other ?
read 691 times 6/23/2011 2:06:35 PM (last edit: 6/23/2011 2:10:49 PM)

Garp 
"in your natural language..." Tu veux l'explication en français? :D
At this point, you have two arrays:  all_boxes that holds the boxes and is used later to access them through their index.  sorted_box_sets that contains one bitarray per level of boxes, which in turn contains the indices for that level. You can see the second array as a lookup table for the first.
For a particular pair of boxes (as long as they're not on the same level), you want all the boxes of the levels in between. But for the top and bottom levels, you need only the start and end boxes.
So the next part would be:  find the two bitarrays in sorted_box_sets that contain the bottom and top boxes.  use some clever way to go through each possible path, one at a time, using one box per level in between. That is, if you select the bottom and top boxes to be on levels, say, 2 and 6, you need only the bitarrays corresponding to levels 3, 4 and 5.
read 679 times 6/23/2011 3:06:19 PM (last edit: 6/23/2011 3:06:19 PM)

aca88 
heh, Non, je suis ok avec l'anglais :P
yes i figured out the arrays. will come back as soon as i write something. thanks again!
read 675 times 6/23/2011 3:20:02 PM (last edit: 6/23/2011 3:20:02 PM)
