echiappe / BonsaiClub

Repository with materials for Chiappe Lab's Bonsai Club
0 stars 0 forks source link

Read matrix from a txt file #9

Closed miguel-paco closed 1 year ago

miguel-paco commented 1 year ago

I have these txt files with the transformation matrixes between units. Each line is a row of the matrix and the columns are separated with ','. MMc2PXc.txt

In the end the following operation is done to convert units

(xn, yn) = unit n (xm, ym) = unit m 3x3 Matrix [a,b,c; d,e,f; g,h,i]

xm = (axn + byn + c) / (gxn + hyn + i) ym = (dxn + eyn + f) / (gxn + hyn + i)

How would I implement the reading of the matrix to do these operations in bonsai? Or should we just use a python script?

bruno-f-cruz commented 1 year ago

Use a CsvReader node with %f,%f,%f as a scan pattern. One way to turn it into a matrix is to just assemble it in an Float[][]. Then use ExpressionTransforms or the Index operator to access its elements.

MatrixBuilder.zip