Wouldn't this be a whole lot easier if you used objects?I am coming to the conclusion - not a great theoretical concept or exhaustive examination of 6+ years of flashcoders posts - that most forum questions that mention arrays of arrays would be a lot easier to solve if the questioner had an array of objects.
Most questions would never have got to the point of needing help. I suggest giving it a moments thought at least. Ron sebastian wrote:
ok I found a solution, though it was more of a work-around than a direct resolution of the array comparing routine I was working towards.My solution is to add to a master array all the sub arrays that it finds, and adds them only if unique. I then have a list of all the sub-arrays together in one long 2D array. From this array I can then sort it based on the length of the second element. Then I iterate from the smallest sub array to the largest; but I don't need to do the entire array because by starting small I capture the actual shapes. Still need to refine how to calculate the maximum steps I need to iterate through the master array, but it will always be at least length-1.Maybe this was interesting to someone... :P Sebastian. sebastian wrote:in case it was not clear, I have no problem getting to this point: A = [A,B,C] B = [A,B,C] C = [A,B,C,D,E] D = [C,D,E] E = [C,D,E] where I am stumped is making that into: A = [A,B,C] B = [A,B,C] C = [[A,B,C],[C,D,E]] D = [C,D,E] E = [C,D,E] :) seb. sebastian wrote:Hiya,I'm trying to figure out a way to code my trigonometry so that collections of points are correctly associated with the right geometric objects. These objects are created dynamically [randomly] at run time so I can't know which points belong to which geometric shape.Where I am scratching my head is with the following, I have 5 points: A,B,C,D,EThese 5 points all have little arrays that tell them who they are next to [ie who they should make a shape with]:A = [A,B,C] B = [A,B,C] C = [A,B,C,D,E] D = [C,D,E] E = [C,D,E] My problem is, I need to break C into two arrays: A = [A,B,C] B = [A,B,C] C = [[A,B,C],[C,D,E]] D = [C,D,E] E = [C,D,E] Which results in 2 shapes: [A,B,C] and [C,D,E]And there are not always 5 points, there could be any number of points, less or more, so it could also get more complex like this:A= [A,B] B= [A,B,C,D] C= [B,C,D,E] D= [B,C,D,E] E= [C,D,E,F,G,H] F= [E,F,G,H] G= [E,F,G,H] H= [E,F,G,H] In this second example, it should break into 4 different shapes/arrays: A= [A,B] B= [[A,B],[B,C,D]] C= [[B,C,D],[C,D,E]] D= [[B,C,D],[C,D,E]] E= [[C,D,E],[E,F,G,H]] F= [[C,D,E],[E,F,G,H]] G= [[C,D,E],[E,F,G,H]] H= [[C,D,E],[E,F,G,H]] which results in these 4 shapes: [A,B],[B,C,D],[C,D,E],[E,F,G,H]Can anyone think of a good way [not processor heavy] for me to correctly create sub-arrays that match the points being generated? The only way I can think of is doing some complex array compares, by building arrays from arrays of other arrays... but that seems convoluted...?Thank you so much, Sebastian._______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders