  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 # Glm Quaternion lookat function ## Glm Quaternion lookat function Tag : cpp , By : AnToni00 Date : November 25 2020, 01:01 AM Boards Message : You Must Login Or Sign Up to Add Your Comments .

## Quaternion "lookAt" function

Tag : c , By : Ben Brown
Date : March 29 2020, 07:55 AM
seems to work fine Im struggling with the following problem. Im working with bone animation and I want (ie) the head of the player to follow an another object in space. My up axis is +Z my forward axis is +Y, and the magnitude of the quaternion is in W. I tried to use the mesa code for gluLookAt and use the 3x3 matrix to transform to a quaternion but it doesn't work as expected so I go in another direction... , I think this function will do what you need:
``````/// <summary>
/// Evaluates a rotation needed to be applied to an object positioned at sourcePoint to face destPoint
/// </summary>
/// <param name="sourcePoint">Coordinates of source point</param>
/// <param name="destPoint">Coordinates of destionation point</param>
/// <returns></returns>
public static Quaternion LookAt(Vector3 sourcePoint, Vector3 destPoint)
{
Vector3 forwardVector = Vector3.Normalize(destPoint - sourcePoint);

float dot = Vector3.Dot(Vector3.forward, forwardVector);

if (Math.Abs(dot - (-1.0f)) < 0.000001f)
{
return new Quaternion(Vector3.up.x, Vector3.up.y, Vector3.up.z, 3.1415926535897932f);
}
if (Math.Abs(dot - (1.0f)) < 0.000001f)
{
return Quaternion.identity;
}

float rotAngle = (float)Math.Acos(dot);
Vector3 rotAxis = Vector3.Cross(Vector3.forward, forwardVector);
rotAxis = Vector3.Normalize(rotAxis);
return CreateFromAxisAngle(rotAxis, rotAngle);
}

// just in case you need that function also
public static Quaternion CreateFromAxisAngle(Vector3 axis, float angle)
{
float halfAngle = angle * .5f;
float s = (float)System.Math.Sin(halfAngle);
Quaternion q;
q.x = axis.x * s;
q.y = axis.y * s;
q.z = axis.z * s;
q.w = (float)System.Math.Cos(halfAngle);
return q;
}
``````

## Handling Quaternion "LookAt" function - Keeping the character upright

Tag : development , By : CSCI GOIN KILL ME
Date : March 29 2020, 07:55 AM
hope this fix your issue Such kind of operation better to perform with matrixes Calculating a LookAt matrix
Than convert back to quaternion.

## Quaternion to EulerXYZ, how to differentiate the negative and positive quaternion

Tag : cpp , By : Sascha Brossmann
Date : March 29 2020, 07:55 AM
it fixes the issue The quaternions -q and q are different; however, the rotations represented by the two quaternions are identical. This phenomenon is usually described by saying quaternions provide a double cover of the rotation group SO(3). The algebra to see this is very simple: given a vector represented by quaternion p, and a rotation represented represented by a quaternion q, the rotation is qpq^{-1}. On the other hand, -qp(-q)^{-1} = -1qp(q)^{-1}(-1) = q(-1)p(-1)q^{-1} = qp(-1)^2q^{-1} = qpq^{-1}, the same rotation. Quaternions normally don't commute, so pq != qp for general quaternions, but scalars like -1 do commute with quaternions.
I believe ToEulerXYZ should be the same in both cases, which it appears to be.

## Converting glm::lookat matrix to quaternion and back

Tag : cpp , By : Jim Davis
Date : November 24 2020, 05:44 AM

## Cesium JS flying to camera.lookAt (Migrating from Google Earth Plugin API lookAt)

Tag : google-maps , By : Navin
Date : March 29 2020, 07:55 AM 