How to build a matrix for rotating a square around itself? Hi, Say I have a square with the following vertices in world position. topleft=100,100 bottomRight= 200,200 So the center is at 150,150 So my local to world matrix should be a translation T to 150,150 (if my for vertices where offset around the origin by 50 in local space) Now, this is what I tried to build my rotation matrix. Compute Tinv as the inverse of T to come back to local space. Compute R as the rotation matrix around 0,0,1 axis with pi/2 as the angle. So my plan to builld this matrix was to first come back to local space, then rotate, then go back to world space. F = Tinv * R * T And that doesn't work. It does work when I apply those matrices independently though, so like: rotatedTopLeft = topLeft * TInv rotatedTopLeft = rotatedTopLeft * R rotatedTopLeft = rotatedTopLeft * T But what I want is combine TInv, R and T into a single matrix so I can just do rotatedTopLeft = topLeft * F So how exactly do I compute F? Thanks 🙂 https://ift.tt/eA8V8J
Hi, Say I have a square with the following vertices in world position. topleft=100,100 bottomRight= 200,200 So the center is at 150,150 So my local to world matrix should be a translation T to 150,150 (if my for vertices where offset around the origin by 50 in local space) Now, this is what I tried to build my rotation matrix. Compute Tinv as the inverse of T to come back to local space. Compute R as the rotation matrix around 0,0,1 axis with pi/2 as the angle. So my plan to builld this matrix was to first come back to local space, then rotate, then go back to world space. F = Tinv * R * T And that doesn't work. It does work when I apply those matrices independently though, so like: rotatedTopLeft = topLeft * TInv rotatedTopLeft = rotatedTopLeft * R rotatedTopLeft = rotatedTopLeft * T But what I want is combine TInv, R and T into a single matrix so I can just do rotatedTopLeft = topLeft * F So how exactly do I compute F? Thanks 🙂
from GameDev.net https://ift.tt/2YB3mwU
from GameDev.net https://ift.tt/2YB3mwU
ليست هناك تعليقات