Help with translating points from Processing for use in Grasshopper

Hi, can someone help with what is likely a simple question from an inexperienced processing user.

I would like to import raw point data from face osc using this method:

I would like to translate the coordinate system for x,y, and z and print to the PrintWriter stream as a vector to be read using grasshopper’s Import coordinates node.

but I am unclear on how to apply it to the array coming from face osc.

To translate the coordinate system for the x, y, and z values coming from FaceOSC, you can apply a transformation matrix to each point in the rawArray. A transformation matrix is a mathematical representation of a geometric transformation such as a translation, rotation, or scaling.

To apply a transformation matrix to a point (x, y, z), you can multiply the matrix and the point as follows:

float[] transformedPoint = {
  x * matrix[0] + y * matrix[4] + z * matrix[8] + matrix[12],
  x * matrix[1] + y * matrix[5] + z * matrix[9] + matrix[13],
  x * matrix[2] + y * matrix[6] + z * matrix[10] + matrix[14],
  x * matrix[3] + y * matrix[7] + z * matrix[11] + matrix[15]
};

Here, matrix is the transformation matrix and transformedPoint is the transformed point.

To write the transformed point to a PrintWriter stream as a vector, you can use the write() method of the PrintWriter class. For example:

PrintWriter writer = new PrintWriter(new FileOutputStream("output.txt"));
writer.write(transformedPoint[0] + " " + transformedPoint[1] + " " + transformedPoint[2]);
writer.close();

This will write the x, y, and z values of the transformed point to a file called “output.txt” as a space-separated vector.