Placing scaled/rotated item in world coords

I want to scale and rotate an object (relative to its centre) but then place it at a specific location in the original (world) coordinate system. If the matrices are S, R and T what is the best way?

TRS won’t work presumably (because T is in world coords). Is it something like inv(RS)TRS ?

What you usually do is first move the object to the center of the world. You do this by finding the center of the object and translating to the center. Then you scale and rotate it, then you move it to the world placement.

In pseudo OpenGL code, this would be

glTranslate(finalPositionX, finalPositionY, finalPositionZ) //places it in the world
glScale(sx, sy, sz);
glTranslatef(-centerObjX, -centerObjY, -centerObjZ) //this centers the object in the center of the world coordinate system

Lets takes a look at what you have:

Let s=scaling factor, c=center of object in object coordinates, and t=location of object in world coordinates.

and we want: p_world= t + s*(p_object-c)

Lets break it down:

p_object - c means put coordinates so that center of the object is the origin
this is the glTranslatef(-centerObjX, -centerObjY, -centerObjZ)

s*(p_object -c ) means scale the object
this is the glScale(sx, sy, sz);

and t + s*(p_object-c) means move it in the world
this is the glTranslate(finalPositionX, finalPositionY, finalPositionZ)

More generally speaking, I have found the the following notation conventions makes deciding how to concat transformations much easier: Suppose you have two coordinate systems, for this example lets say world and object1, then:

Let world_matrix_object be the matrix so that p_world= world_matrix_object*p_object, i.e. transforms points in object coordinates to points in world coordinates.

Nice things are:

[ul][li] A_matrix_B= inverse(B_matrix_A)[*] A_matrix_C= A_matrix_B * B_matrix C[/ul][/li]
Given world_matrix_object, construct a new world_matrix_object corresponding to

a) scaling the object by a factor lambda
b) rotating the object about it’s origin (i.e. like Earth rotating on it’s axis)
c) rotating the object in the world (i.e. like Earth rotating about the sun)

The above matrix convention/notation can be helpful… atleast that is the way I usually do it :smiley: