Link to home
Start Free TrialLog in
Avatar of _faraz
_faraz

asked on

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
Avatar of cmreichl
cmreichl

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
Avatar of _faraz

ASKER

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.

hmm...I'll give this ago, thanks for your help (got me thinking about this in a different way!)

faraz
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial