Structures

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++)
      {
            j=s2d[i][n];
            q.push(j);
         }
 
      }
 
   result.s1d=q; 
   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 ;)

Fiducials

11's picture

Hi there monsters! :) I've been reading this lovely forum since 3 months ago and now I feel to get started posting my problems and hope I will have your lights through my way.. I'm going to have this fiducials have visual feedbacks,so I started from the very basic steps... The problem I have right now is how to make each Fiducual ID separated for different visual feedbacks? I'm guessing to use structure thingies but imagine me as a noob person both in coding and QC.. cheers

Javascript output structure error

benoitlahoz's picture

Hi !

Firstable, a big thanks for this site and the contributors ! This is a bible, and I can say that I'm learning QC at Kineme !

Here is my trouble, and I guess this is a simple problem of variable declaration in Javascript... But well... I can't manage to output a structure from this code !

In input I have a structure of 4 values structures (Mesh vertices). What I want is to output a new structure of 3 values structure (Points structure), so for each substructure I "pop" the last element.

But my code seems to be wrong and it returns an error : "TypeError : Result of 'MeshVerticesArray' [null] is not an object".

Here is the code :

function (__structure LineStructure) main (__structure MeshVerticesArray)
{
   for (i = 0; i < MeshVerticesArray.length; i++) {
 
      for (j = 0; j < 3; j++) {
 
         LineStructure[i][j] = MeshVertices[i].pop();
 
      }
 
   }
   var result = new Object();
   result.LineStructure = LineStructure;
   return result;
}

Could you please help me ? Am I doing things the right way ?

Thanks a lot in advance !

Ben

Nested structure (leafed) (Composition by usefuldesign.au)

Author: usefuldesign.au
License: (unknown)
Date: 2010.07.04
Compatibility: 10.5, 10.6
Categories:
Required plugins:
(none)

This is a tutorial composition demonstrating the difference of item indexes and keys when both are numbers generated within, in this case, a Javascript patch.

Was made in response to the question on this thread Sorting Part Structure

Help with Structures and Javascript

0101000101000011's picture

Hello. I'm seeking information/tutorials on using structures and Javascript in QC. Separately and together that is. What are structures, what all can they be used for and how? Same for Javascript. XML MIDI structures? I've used many objects that take structure input, as well as objects that modify a structure, and deconstructed some Javascript to try and understand how it's working. Thats been pretty much my learning curve in QC so far. Figure it out through cause and effect...

One thing that's been on my mind for a while is, somehow making an application for a Monome with QC that would visualize different data sources synced to a tempo. I'm thinking, it's probably possible, but more likely easier programmed in Max. Of which I have very little knowledge. Thus I'm thinking a better knowledge of structures and javascript may yield such an app. I just don't know where to start... I should really just learn Max and build these as M4L devices as they probably won't run as efficient as VDMX plug-ins...

Anyways... Structures and javascript in visual compositions... Rather than control^ Any responses, or perhaps demonstration comps would be greatly appreciated. Thanks.