# xz oriented quad following camera(quaternion,matrix)

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

## Recommended Posts

i have a quad ( pos(0,0,0), normal(0,1,0) ) that is oriented in xz ( by 45 deg in model space ). Camera is above it by a given elevation ( change with cam movements ). The quad must always follow camera ( xz axis only, x(1,0,0) z(0,0,1) ). the orientation of the quad in xz (45 deg) must remain the same when view from camera. visual example : I can access camera orientation (quaternion), position (vector3) and view matrix(directx matrix). How can i build a matrix that makes the quad fulfill all the conditions ? Thx

##### Share on other sites
I hope I understood your desire correctly. The following steps assume that the camera is given w.r.t. the global co-ordinate frame, and that the model should be given in that frame.

Convert the quaternion to a matrix and isolate the "front" orientation vector from it. Set its y component to 0 and re-normalize the result (of course, you have to catch the cases when looking straight up or down since then the said vector is 0). Use this vector and the original orientation vector of the plane (i.e. those denoting the principal direction of the corner you want to look at coarsly) inside a dot-product and cross-product to compute an axis/angle pair for a rotation matrix. Then isolate the position from the camera and again set the y co-ordinate to 0 (assuming that 0 is the height level of the plane). Compute a translation matrix from that vector. Then concatenate both new matrices to yield in the model-to-global transformation.

##### Share on other sites
thx for the answer. The orientation that result from your suggestion has a fixed y angle and we can look around xz like a lighthouse lamp. I am looking for
the opposite : xz angle is fixed and we can look around y angle like a big wheel. Sorry that my first post isn't as understandable as it should be.

##### Share on other sites
When using the inverse of your suggested matrix, it works fine. Thx

1. 1
2. 2
Rutin
25
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 20
• 14
• ### Forum Statistics

• Total Topics
632950
• Total Posts
3009378
• ### Who's Online (See full list)

There are no registered users currently online

×