Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What is 'trace' in quaternions?

I've been recently learning about quaternions and the amazing things you can do (mainly slerp for rotational smoothness), and looking through the code on the wiki, there is nothing about this part which is explained or anything, it's just there. Can someone please help me understand what this variable is and what role it plays in the quaternion?

local trace=m00+m11+m22
if trace>0 then
	local s=math.sqrt(1+trace)
	local r=0.5/s

Thanks in advance!

2 comments

0

That's a tough one... xD I still am a noob in LUA.

0

Trace refers to the trace of a matrix. Which is just the sum of its diagonal. The snipped you posted is just a part of the conversion between a rotation matrix and quaternions

1 answer

In order to convert from a matrix to a quaternion you need to know the axis of rotation and angle that got you from the identity rotation to the current rotation. As lombardo2 mentioned, the trace is simply the sum of the diagonal elements in a matrix and is used in the process of calculating the axis and angle.

This process can get quite messy, but if you are interested in seeing why this works I wrote something about it:

https://egomoose.github.io/Angle_and_axis_of_rotation_from_rotation_matrix.html

This discussion is preserved as it was. New answers, comments, and votes are closed.