-Chris

Solved

Posted on 2004-09-16

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

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

4 Comments

Comment Utility

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

-Chris

Comment Utility

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

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

Comment Utility

PAQed, with points refunded (250)

Computer101

E-E Admin

Computer101

E-E Admin

Title | # Comments | Views | Activity |
---|---|---|---|

Network game - UDP safety concerns? | 10 | 253 | |

Game needs - How much would Reese Witherspoon or Buffy charge per hour? | 4 | 151 | |

JAXB showroom collection | 2 | 91 | |

factorial example challenge | 10 | 61 |

This video discusses moving either the default database or any database to a new volume.

Join the community of 500,000 technology professionals and ask your questions.

Connect with top rated Experts

**12** Experts available now in Live!