Author Topic: rotation by matrix  (Read 2383 times)

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
rotation by matrix
« on: March 12, 2010, 08:03:57 am »
i have a rotation matrix multiplied by a uniform scale matrix.

* SimpleVector.rotate(matrix) also applies scaling to vector, is this intentional ?
* how can i check rotation part (upper 3x3) of matrix has no scale information ?
* how can i clear scaling from matrix ? assuming i dont know scaling value

thanks

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: rotation by matrix
« Reply #1 on: March 12, 2010, 08:28:33 am »
Yes, that is intentional... ;D


Maybe this works (as long as the scaling is uniform):

  • create a SimpleVector of length 1 (for example 1,0,0)
  • multiply it with the matrix
  • calculate it's length
  • if it's not 1, do a scalarMul on the matrix with 1/length

Should work, but might not be the best or fastest way to do it...only a pragmatic way.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: rotation by matrix
« Reply #2 on: March 12, 2010, 08:44:05 am »
yes it works, thanks :)

so, assuming there is no translation in matrix, multiplying it with scalar is practically the same as multiplying with a uniform scale matrix. and of course less expensive. i didnt know this

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: rotation by matrix
« Reply #3 on: March 12, 2010, 08:58:18 am »
Just do it once on paper and you'll see... ;)