I taught a hand how to walk using machine learning. Has science gone too far? https://t.co/SBkK8G3jme pushmatrix さんのツイートから

seen from Türkiye
seen from Russia
seen from China
seen from Netherlands

seen from Netherlands
seen from China
seen from Netherlands

seen from Greece

seen from United States
seen from United States

seen from Australia
seen from United States

seen from Thailand
seen from China
seen from India
seen from Türkiye
seen from Thailand

seen from United States

seen from Maldives
seen from Japan
I taught a hand how to walk using machine learning. Has science gone too far? https://t.co/SBkK8G3jme pushmatrix さんのツイートから

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Miniature Beat Saber. Would you play it? https://t.co/LtKgXB2Z4B http://twitter.com/pushmatrix/status/1260209543864356865
via @pushmatrix
Miniature Beat Saber. Would you play it? pic.twitter.com/LtKgXB2Z4B
— Daniel Beauchamp (@pushmatrix) May 12, 2020
via @pushmatrix
Playing frogger in AR with a 3D scan of myself. pic.twitter.com/Zt6H36aG6U
— Daniel Beauchamp 🔜 OC6 (@pushmatrix) September 13, 2019
After all these months of programming, I still have to fully understand how pushMatrix() and popMatrix() work.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Translate, Rotate, Draw. (More Pushing and Popping)
Experimenting a bit further with matrix co-ordinates, I realised that its quite easy to forget which order that you are supposed perform the order of things, so I (badly) drew an easy to follow diagram that shows me how to do it.
Step 1. The initial step, the matrix 0,0 co-ordinate starts at the top left hand corner of your window. If you are using more than one it is here that you will pushMatrix().
Step 2. The translation step, the matrix is moved along the x and y axis to your desired spot.
Step 3. The rotation, the matrix is rotated through the z axis.
Step 4. Drawing, you can now draw whatever you want on the matrix. It is here that you would call the popMatrix() if you needed to draw on another matrix.
This sketch uses the translate, rotate and push and pop matrix functions to rotate rectangles held in an ArrayList as the mouse hovers over them.
class Square { int x, y; int sideLength = 50; int pen = 1; int r = 120; Square() { x = (int)random(width-sideLength); y = (int)random(height-sideLength); } Square(int x1, int y1) { x=x1; y=y1; } void drawSquare() { strokeWeight(pen); fill(r,0,0); pushMatrix(); translate(x,y); rect(0,0,sideLength, sideLength); line(-sideLength/2,-sideLength/2,sideLength/2,sideLength/2); popMatrix(); } void drawRotatedSquare() { strokeWeight(pen); fill(r,255-r,r); pushMatrix(); translate(x,y); rotate(90*PI/180); rect(0,0,sideLength, sideLength); line(-sideLength/2,-sideLength/2,sideLength/2,sideLength/2); popMatrix(); } boolean mouseOver(int mx,int my) { if ( mx >= x-sideLength/2 && mx < x+sideLength/2) { if ( my >= y-sideLength/2 && my < y+sideLength/2) { return true; } else return false; } else return false; } } Square sq; ArrayList sqs = new ArrayList(); int rotCount = 0; void setup() { rectMode(CENTER); size(500,500); for (int y = 0; y<height-50; y+=100) { for (int x = 0; x < width-50; x+=100) { sq = new Square(x+50,y+50); sqs.add(sq); } } } void draw() { rotCount = 0; background(190,0,0); int listSize = (sqs.size()); Square s; for (int i = 0; i<listSize; i++) { s = (Square)sqs.get(i); if (s.mouseOver(mouseX,mouseY)) { s.pen = 6; s.r = (int)random(255); s.drawRotatedSquare(); } else { s.pen = 1; s.drawSquare(); } } }
Pushing and Popping
Being a bit lazy it's taken me quite a while to work out how pushMatrix() and popMatrix() actually work and why I would need them. Whenever I have tried to rotate things around point before they've just gone whizzing off around the screen and in no apparent order whatsoever so I went off in a huff and did something else instead. Today I decided to sit down and actually see where I was going wrong.
With the help of these three helpful pages:
1. Daniel Shiffman's Learning Processing 2. Tlll Nagel's Creative Coding 3. Critical Zero
The rotate() function in Processing rotates the entire co-ordinate matrix which means that everything rotates around the same centre point. A co-ordination matrix is like a glass surface with images drawn onto it which can then me moved around or rotated. Calling the pushMatrix() function adds another co-ordinate matrix which would be similar to placing another glass surface over the original, this can also be moved and rotated and drawn on without effecting the original. The popMatrix() function then returns you to the previous matrix and allows you to work on that.
This is a simple sketch that fills the screen with rectangles and using pushing and popping rotates each of them around their centre points:
float angle = 0; void setup () { size(500,500); rectMode(CENTER); } void draw() { background(0); angle+= 0.05; for (int y = 0; y < height-50; y+=50) { for (int x = 0; x < width-50; x+=50) { pushMatrix(); translate(50+x,50+y); rotate(angle); rect(0,0,50,50); popMatrix(); } } }