3d > 2d transform - How can I do this.

leafcutter's icon

Hello, I've been working with a plotter recently.

View this post on Instagram

DistArc

A post shared by Leafcutter John (@leafcutterjohn) on

And it's got me wondering how I can translate between 3d (x,y,z) data to 2d(x,y) that I can plot?

Say I have a torus like this:

Max Patch
Copy patch and select New From Clipboard in Max.

What's the best way to project it into 2 dimensions? I don't have a clue where to begin.

Thanks for any pointers.

J

Rob Ramirez's icon

loving those plot images John!

i would suggest iterating through the geometry (use matrixoutput 2 to include the spatial transform) and using worldtoscreen to get screen coordinates. basic example using jit.mgraphics below.

note though that this example is just drawing lines between subsequent vertices. for more sophisticated drawing (e.g. the triangle grid drawing of the gl.mesh) you'll have to adjust the algorithm.

Max Patch
Copy patch and select New From Clipboard in Max.

leafcutter's icon

Thanks Rob, that's absolutely brilliant!

Rob Ramirez's icon