Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

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
Asked:
_faraz
1 Solution
 
cmreichlCommented:
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
 
_farazAuthor 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.

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

faraz
0
 
Computer101Commented:
PAQed, with points refunded (250)

Computer101
E-E Admin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now