Comparing two X,Y,Z structures and generating new one with added indexed values from Serial I/O.

mvesga's picture

Hi, I have an string of comma separated values coming from the Serial I/O which correspond to a 16x16 matrix Array. I'm breaking down the string into a Structure with 16 index members every 16 values, on a queue size of 16 (16x16). I'm struggling trying to generate a structure containing the 256 members (I'm only getting a structure of 34 members) from the array which then I would like to include (and match) to it's corresponding ordered position in an indexed X,Y,Z structure. Problem is that I won't always have the same amount of members in my X,Y,Z structure. So I would like to detect how many values are actually active on the 16x16 array and then generate a new structure of 4 members containing the matrix value + the X,Y,Z values for its' corresponding index position. My approach was to compare two sets of X,Y,Z Structures in order to generate a third structure that would be composed of the matching values within the two previously compared structures + the active array values passed through an iterator. Problem is I can't seem to pass on the queued values properly inside iterators; from a 16 sized queued structure of 16 members I'm only getting a structure of 34 members/iterations.

I'm using the following Javascript in order to accomplish this:

function (__structure s1d) main (__structure s2d, __index size, __number len) 
   var result = new Object();
   var j = 0;
   var f=0;
   q=new Array();
   for(var i=0;i<size;i++)   
   f="point00" + i;
   q.push(f); //pass the point names
      for(var n=0;n<len;n++)
   return result;

Given my limited javascript knowledge I haven't been able to achieve this. Would be great if anyone could point me in the right direction or know how to solve this. Any help would be highly appreciated! and would definitely earn some good karma points ;)

Quad from vector

yanomano's picture

Hi , i'am trying to build a quad from a vector to control its orientation. Basicaly the same idea than building a polygon from an arbitrary normal. I can't do a Cross Product...needs 2 vectors... After some investigations and tests, it looks like a simple rotation matrix will not suffice to drive the other perpendicular vectors needed to retrieve the vertices.

Apparently it is the big jump to quaternions....Can somebody Confirm ?

Camera transform matrix

SteveElbows's picture

Im mucking around with Apple Motion 4. Motion is a 2.5D app. I notice that its API for writing plugins enables plugins to receive information about where the camera & object are in 3D space. I also notice that FxFactory Pro seems to have the ability to pass camera transform matrix and layer transform matrix to quartz compositions when fxfactory is used within motion.

Here is the fxfactory page that mentions this:

Unfortunately I know very little about matrix stuff and Im not quite sure how to handle it in Quartz Composer if I was trying to make a plugin for motion using quartz composer and have the view of a 3d object in the .qtz change as I move the camera or object within motions 3D space.

Any ideas where to start? Or if anybody knows of any existing quartz file or any of the fxfactory plugins that use this technique, because I dont even know how well motion handles this stuff.