Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions HelpSource/Classes/Quaternion.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ METHOD:: distance
Return the distance between two quaternions.


METHOD:: rotate
Return the rotation (yaw) Euler angle in radians. Returns values between -pi and pi (-180 and 180 degrees).


METHOD:: tilt
Return the tilt (roll) Euler angle in radians. Returns values between -pi and pi (-180 and 180 degrees).


METHOD:: tumble
Return the tumble (pitch) Euler angle in radians. Returns values between -0.5pi and 0.5pi (-90 and 90 degrees).


EXAMPLES::
Expand Down
6 changes: 3 additions & 3 deletions classes/various/Quaternion.sc
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ Quaternion {

// roll
tilt {
^atan2((2 * (a * b - (c * d))), (1 - (2*(b.squared + c.squared))))
^atan2((2 * (a * b + (c * d))), (1 - (2 * (b.squared + c.squared))))
}

// pitch
tumble {
^asin((2 * (a * c + (b * d))).clip(-1.0, 1.0));
^asin((2 * (a * c - (b * d))).clip(-1.0, 1.0));
}

// yaw
rotate {
^atan2((2 * (a * d - (c * b))), (1 - (2*(d.squared + c.squared))))
^atan2((2 * (a * d + (c * b))), (1 - (2 * (d.squared + c.squared))))
}
}

Expand Down