  C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD # 3-axes quaternion rotation in OpenGL  » cpp » 3-axes quaternion rotation in OpenGL

By : user2950392
Date : November 17 2020, 11:55 AM
Hope that helps Your code is using Euler angles (axis-aligned rotations). The wiggles and jumps are because Euler angles are a bad parameterization of the space of 3D rotations. Instead, here are two alternate approaches.
Constructing a Rotation Matrix via a Frame code :
``````f = v/|v|
up = p/|p|
s = cross(f, up)
``````
``````[  f   f  f ]
[ up  up up ]
[  s   s  s ]
`````` ## Quaternion rotation opengl

By : The Discreet
Date : March 29 2020, 07:55 AM
hop of those help? If i make a quaternion which represents for example a players direction and the angle around this rotation. So for the application I intend to make a plane flying. The quaternion would represent the players direction and the angle around this direction. , I hope I understand the question correctly. ## Body axes to earth axes using rotation matrix? [openGL]

By : Paresh Khatri
Date : March 29 2020, 07:55 AM
Any of those help A tutorial on rotation matrices, as well as the integration you need is described in the
Direction Cosine Matrix IMU: Theory ## iOS OpenGL ES 2.0 Quaternion Rotation Slerp to XYZ Position

By : Arnav Roy Karforma
Date : March 29 2020, 07:55 AM
will help you The answer to this question is a combination of the following rotateTo function and a change to the code from Ray's tutorial at ( http://www.raywenderlich.com/12667/how-to-rotate-a-3d-object-using-touches-with-opengl ). As one of the comments on that article says there is an arbitrary factor of 2.0 being multiplied in GLKQuaternion Q_rot = GLKQuaternionMakeWithAngleAndVector3Axis(angle * 2.0, axis);. Remove that "2" and use the following function to create the _slerpEnd - after that the globe will rotate smoothly to XYZ specified.
code :
``````// Rotate the globe using Slerp interpolation to an XYZ coordinate
- (void)rotateToLocationX:(float)x andY:(float)y andZ:(float)z {

// Turn on the interpolation for smooth rotation
_slerping = YES; // Begin auto rotating to this location
_slerpCur = 0;
_slerpMax = 1.0;
_slerpStart = _quat;

// Create a look at vector for which we will create a GLK4Matrix from
float xEye = x;
float yEye = y;
float zEye = z;
_currentSatelliteLocation = GLKMatrix4MakeLookAt(xEye, yEye, zEye, 0, 0, 0, 0, 1, 0);

// Turn our 4x4 matrix into a quat and use it to mark the end point of our interpolation
_slerpEnd = GLKQuaternionMakeWithMatrix4(_currentSatelliteLocation);

}
`````` ## Converting glm quaternion to rotation matrix and using it with opengl

By : Cman88
Date : March 29 2020, 07:55 AM
Hope that helps GLM won't/can't(?) automagically cast a mat4 to GLfloat* so you have to help it along a bit.
Try this:
code :
``````#include <glm/gtc/type_ptr.hpp>
glMultMatrixf( glm::value_ptr( glm::mat4_cast(orientation) ) );
``````
``````glMultMatrixf( &glm::mat4_cast(orientation) );
`````` ## What is wrong with my Quaternion rotation in OpenGL?

By : zif001
Date : March 29 2020, 07:55 AM
it should still fix some issue Going off notes on the internet helps construct quaternion classes properly. My problem is putting them to practical use and using them for rotations in raw OpenGL. ,
code :
``````glRotatef(qRot.x, 1., 0, 0);
glRotatef(qRot.y, 0, 1., 0);
glRotatef(qRot.z, 0, 0, 1.);
``````
``````template<class T>
mat<T,3,3> mat_rotation(const quat<T> &x)
{
T s = 2/norm2(x); // cheap renormalization even of non-unit quaternions
T wx = x.w*x.x, wy = x.w*x.y, wz = x.w*x.z;
T xx = x.x*x.x, xy = x.x*x.y, xz = x.x*x.z;
T yy = x.y*x.y, yz = x.y*x.z;
T zz = x.z*x.z;

return mat<T,3,3>(
1 - s*(yy+zz),  s*(xy-wz),  s*(xz+wy),
s*(xy+wz),  1 - s*(xx+zz),  s*(yz-wx),
s*(xz-wy),  s*(yz+wx),  1 - s*(xx+yy)
);
}
`````` 