• Status: Solved
• Priority: Medium
• Security: Public
• Views: 207

# geometry tranform problem

Hi,

My linear algreba's a little shaky, hence the question...

I have a non axis aligned box parameterised something like:

vector3 center
vector3 extents
vector3 eulers

To draw this thing I apply transformations like this:

extents -> eulers -> center
ie. scale -> rotate -> translate

I want to recalculate the translate when I update the scale to give the same tranformation such that a particular side of the box remains in the same position.

The box is editable by the user who can pull the edges to scale the box, or use a widget to rotate the box. With zero rotations the box behaves ok, I calculate the center to compensate for the adjusted edge. However when the box is rotated this calculation is not so simple I cannot get the same behaivour, the box moves around.

The end result needs to be a 4x4 matrix that represents the tranformation so there maybe another representation would be better.

Any help really appreciated.

faraz
0
_faraz
1 Solution

Commented:
The reason for this behavior is that the rotation equations your using are doing calculations about the origin...   Therefore if your object is not at the origin the whole object is then rotated as if the origin was its center.  An easy fix would be to remember its center, convert the numbers to the origin, and then convert back once rotation is calculated.  (Since your just calculating numbers and not actually moving the object, this isn't an inefficient method).

-Chris
0

Author Commented:
This was my original 'solution', however it doesn't really give the expected (from the user's point of view) result. The user expects the rotation to occur about the current center of the box, not the original center. As the box is scaled the center obviously shifts, the rotation occurs around the correct center before the translation is applied, but this invalidates the translation.

I think the problem is actually more to do with keeping the opposite edge to the one thats begin moved stationary.

It may be simpler to work by transforming faces/vertices (user experience is the same) then calculate the matrix from the vertices when I need it, maybe with the coord frame defined by the planes since this bit is not performance critical. That way I'm not dealing with a representation based on transformations, I just apply a transformation to vertices as I need it.

faraz
0

Commented:
PAQed, with points refunded (250)

Computer101