Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Known:
- The vertices: a.x, a.y, b.x, b.y, c.x, c.y, d.x, d.y
- Unknown:
- the scaling factor: k
- the rotation factor: theta
- the translation vector: v.x, v.y
- matrix form:
- [scaling matrix] * [rotation matrix] * [translation matrix] * [a and b] == [c and d]
- +-- --+ +-- --+ +-- --+ +-- --+ +-- --+
- | k 0 0 | | cos(theta) -sin(theta) 0 | | 1 0 v.x | | a.x b.x | | c.x d.x |
- | 0 k 0 | * | sin(theta) cos(theta) 0 | * | 0 1 v.y | * | a.y b.y | == | c.y d.y |
- | 0 0 1 | | 0 0 1 | | 0 0 1 | | 1 1 | | 1 1 |
- +-- --+ +-- --+ +-- --+ +-- --+ +-- --+
- multiply first three matrices
- +-- --+ +-- --+ +-- --+
- | k * cos(theta) k * -sin(theta) (k * cos(theta) * v.x + k * -sin(theta) * v.y) | | a.x b.x | | c.x d.x |
- | k * sin(theta) k * cos(theta) (k * sin(theta) * v.x + k * cos(theta) * v.y) | * | a.y b.y | == | c.y d.y |
- | 0 0 1 | | 1 1 | | 1 1 |
- +-- --+ +-- --+ +-- --+
- Equivalent series of equations:
- (k * cos(theta) * a.x + k * -sin(theta) * a.y + (k * cos(theta) * v.x + k * -sin(theta) * v.y)) = c.x
- (k * cos(theta) * b.x + k * -sin(theta) * b.y + (k * cos(theta) * v.x + k * -sin(theta) * v.y)) = d.x
- (k * sin(theta) * a.x + k * cos(theta) * a.y + (k * sin(theta) * v.x + k * cos(theta) * v.y)) = c.y
- (k * sin(theta) * b.x + k * cos(theta) * b.y + (k * sin(theta) * v.x + k * cos(theta) * v.y)) = d.y
- Goal:
- solve for k, theta, and v
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement