0

In a 3d space I have a 3d object which I am rotating using a transformation matrix. The transformation matrix is 4x4 but I am just using the rotation part of the matrix. I want to add constraints to the rotation for example the object can only rotate in the z direction for 20 degrees. I know the following but when I add manual constraints such as angle cant be larger than 20 i get scaling and skewing in my object.

enter image description here

To summarize my question how can I add constraints to a transformation matrix?

genpfault
  • 51,148
  • 11
  • 85
  • 139
beavis578
  • 31
  • 2
  • 8
  • What do you mean by only the _rotation part_ of a 4x4 matrix? The left upper 3x3 submatrix? – Stefan Hanke Feb 13 '15 at 05:20
  • I think beavis means he's only multiplying a vec3 (x, y, z, no w) by these matrices. These matrices look fine to me, and you should have no problem putting constraints on the angles. It would be good to show us some code about how you're using/constraining these matrices. – jwlaughton Feb 13 '15 at 05:32
  • the upper left element of matrix is x coordinate of X-axis vector, without scaling it is unit vector so the constraint should be that this element Xx is in range `` this of coarse will not work on full circle but for 20 degrees is fine unless crossing quadrants ... so if it is out of range then ignore the rotation or set the matrix as the constrained (precomputed) to closer edge. If you use also another rotations or skew/scale then this will not work as expected look here http://stackoverflow.com/a/28084380/2521214 – Spektre Feb 13 '15 at 08:02
  • For more complex rotation use and constrains are better Euler angles ... – Spektre Feb 13 '15 at 08:07
  • I don't think you can add constraints into a transformation matrix as the matrix itself has no places to hold constraint information. The only thing you can do is to construct the transformation matrix conforming to your constraints. – fang Feb 13 '15 at 18:53

1 Answers1

0

The short answer, you should add constraints to your Euler Angle representation.

If you keep rotation only in matrix form, than convert it to Euler Angle representation, apply constraints and convert Euler Angle to matrix form.

NOTE: Your Rx Ry Rz representation is called "Euler Angels" http://en.wikipedia.org/wiki/Euler_angles. There is a many ways to combine rotations about orthogonal axes. code for all conversions can be taken from http://tog.acm.org/resources/GraphicsGems/gemsiv/euler_angle/

minorlogic
  • 1,872
  • 1
  • 17
  • 24