Rotate and Scale Around Different Origins using Local Coordinates

48 Views Asked by At

How can I chain rotate and scale operations (each with different origins) while keeping each operation origin in relation to the original local component space?

Using matrix denotation (i.e. T for translation matrix, R for the rotation matrix, and S for the scaling matrix) I'm performing the following operations on my object:

\begin{gather*} T*R*S \end{gather*}

$T$ takes us from a global to local coordinate frame, then $R$ and $S$ rotate and subsequently scale our object. Since we are rotating and scaling around unique points in the object, the operation breaks down to:

  1. mat = $I$
  2. mat = mat $*$ $T$
  3. mat = mat $*$ translation matrix to $R$ origin $*$ $R$ $*$ translation matrix to $-R$ origin
  4. mat = mat $*$ translation matrix to $S$ origin $*$ $S$ $*$ translation matrix to $-S$ origin

However, this produces an object that is both scaled and rotated with respect to the original object. For example, if we scale by $2$x about the bottom-left corner $(0,0)$ and rotate $45^{\circ}$ about the center $(1.5, 1.5)$ we produce the following:

enter image description here

What operation(s) need to be edited in order to achieve rotating about the newly scaled object's center:

enter image description here