I need to find a way to rotate the camera in its own axis using glulookat. I need to calculate the up vector for this. Assuming the up = {0,1,0} intially. I need to rotate this vector by angle ax,ay,az and find the resulting vector to use in glulookat function. Is there an readymade method or any other easy method rather than applying combined rotation matrix multiplication on the unit vector (0,1,0) to do this?
Have you tried working with Spherical Coordinates? You just get the angles that you need to move with and then transform the spherical to cartezian coordinates and then you should be able to calculate the up vector.
http://en.wikipedia.org/wiki/Spherical_coordinate_system
Related
I've got the following problem:
In 3D there's a vector from fixed the center of a plane to the origin. This plane has arbitrary coordinates around this center thus its normal vector is not necessarily the mentioned vector. Therefore I have to rotate the plane around this fixed center such that the mentioned vector is the plane's normal vector.
My first idea was to compute the angle between the vector and the normal vector, but the problem then is how to rotate the plane.
Any ideas?
A plane is a mathematical entity which satisfies the following equation:
Where n is the normal, and a is any point on the plane (in this case the center point as above). It makes no sense to "rotate" this equation - if you want the plane to face a certain direction, just make the normal equal to that direction (i.e. the "mentioned" vector).
You later mentioned in the comments that the "plane" is an OpenGL quad, in which case you can use Quaternions to compute the rotation.
This Stackoverflow post tells you how to compute the rotation quaternion from your current normal vector to the "mentioned" vector. This site tells you how to convert a quaternion into a rotation matrix (whose dimensions are 3x3).
Let's suppose the center point is called q, and that the rotation matrix you obtain has the following form:
This can only rotate geometry about the origin. A rotation about a general point requires a 4x4 matrix (what OpenGL uses), which can be constructed as follows:
In an OpenGL game, I am trying to rotate the camera relative to the player's view. This rotation is not easily defined by relative angles, but rather easily defined by relative forward/up/left vectors.
How do I construct a matrix such that I can multiply it by the current projection matrix to achieve this rotation?
I have a rotation matrix I use to show a 3D-vector with openGL. Now I would like to have a projection of this vector on the XY-plane. So I´m looking for the rotation matrix that I can use to do this. Any ideas on how to do this?
This will not be rotation matrix, but general 4x4 transformation matrix for doing a projection on a plane. It is often used to do a "shadow" matrix for flattening objects onto a floor.
See more here: http://www.opengl.org/archives/resources/features/StencilTalk/tsld021.htm
https://math.stackexchange.com/questions/320527/projecting-a-point-on-a-plane-through-a-matrix
Projected Shadow with shadow matrix, simple test fails
I have camera that look at cube from above. I can rotate cube so cube can have rotation values like z=258.18594 x=1. I need advice how to get nearest rotation with cube stand on ground and camera see top face.
Look for Quaternion mathematics and Quaternion interpolation. This will make the task rather easy.
See also Nearest Neighbours using Quaternions
I have successfully implemented Arcball rotation through quaternions, but am confused at what to do when the direction vector of the camera is parallel to up vector. Currently I am just restricting the rotation along the x-axis (the pitch) when the dot product of the direction vector and the up vector exceeds 0.99. In Maya (or Max, XSI where arcball rotation is used) for example, you can rotate around in a full circle very smoothly. I am hoping for a solution similar to that of Maya's rotation.
Thankyou
You need to adjust both the view normal vector (VNV) and the view up vector (VUV) and rotate both of them together so they always remain orthogonal to each other. It is sometimes useful to keep track of a "right" (or "left") vector as well which is just the cross product of the normal and up vectors.