# View Matrix Problems

This topic is 4705 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I'm trying add a function to my camera system that will allow me to pass in an eyepoint and and look at point and with that build the view matrix. I can figure out the amount of x and y rotation I need to apply to the matrix but I dont know how to rotate matrix with out using helper functions. So I guess my real question is how do you rotate a matrix along its x and y axis with out helper functions? Thanks

##### Share on other sites
i know in real graphs..actually math you multiply by the transformation matrix if you will. for example if i want to turn the point 1,1 all the way around i'd multiply it by <-1,0> <0,-1>. that would essentially flip flop the point :-D either way, hope that helps. sorry,that's just my basics of linear algebra going on..heh

##### Share on other sites
Generally the basis of a 'lookat' matrix is constructed directly rather than through rotation per se, so you don't need any helper functions. If you google D3DXMATRIXLookatLH and RH, you should find docs that give the form of both the LH and RH versions of the matrix. The only change you might have to make from the docs is to switch from row to column vectors if necessary.

[Edit: Here and here.]

##### Share on other sites
The DX SDK claims that the most straight forward approach to a view matrix is to apply a translation and then a series of rotations as such:

V = T.R(z).R(y).R(x)

where T is a translation matrix that translates the objects to -1*Camera.Pos
R(z) rotates -Camera.RotZ degrees, R(y) rotates -Camera.RotY degrees etc.
Haven't tried it to be honest.

The following produces a view matrix from 3 vectors
/* This is a left handed version. 'At' is the vector to the look-at point, 'Eye' is the vector to the camera, Up is a vector pointing up, usually (0,1,0)*/zaxis = normal(At - Eye)xaxis = normal(cross(Up, zaxis))yaxis = cross(zaxis, xaxis)// This is the matrix[ xaxis.x           yaxis.x           zaxis.x          0][ xaxis.y           yaxis.y           zaxis.y          0][ xaxis.z           yaxis.z           zaxis.z          0][-dot(xaxis, eye)  -dot(yaxis, eye)  -dot(zaxis, eye)  1]

Quote:
 So I guess my real question is how do you rotate a matrix along its x and y axis with out helper functions?

If I understand, you want to know how to rotate sth around its own local-axes and not around the global? This is called a similarity transformation in linear algebra. In short, it's sth like a temporary change of coordinates system (within the multiplication) in order to apply the effects of a specific transformation matrix in another frame of reference. The matrix for a similarity transform is a matrix X' which is derived from a product of this form: " X' = (Y^-1).X.Y ". The similar matrices are X and X' and they have equal determinants.
The idea is that matrices don't change in different coordinates' systems. For example, a rotation matrix around Z, will always be written the same way, no matter what the Z axis. Therefore, you only need to make sure you have the axis right to get the effect you want. This what the Y and its inverse Y^-1 do. They switch to model local axes, apply that transformation in local space, and then transform back to world coords.
I can't be more specific about that, I'm sure you'll find many papers on similarity transformations out there.

1. 1
Rutin
49
2. 2
3. 3
4. 4
5. 5

• 11
• 16
• 9
• 10
• 13
• ### Forum Statistics

• Total Topics
633003
• Total Posts
3009846
• ### Who's Online (See full list)

There are no registered users currently online

×