BSNS102 Study Guide - Final Guide: Linear Interpolation, Atan2, Dot Product

33 views4 pages

Document Summary

Chapter 11: transformations in c++ float sinthetaover2sq = 1. 0f - w*w; // protect against numerical imprecision if (sinthetaover2sq <= 0. 0f) { // return any valid vector, since it doesn"t matter return vector3(1. 0f, 0. 0f, 0. 0f); // compute 1 / sin(theta/2) float oneoversinthetaover2 = 1. 0f / sqrt(sinthetaover2sq); // return axis of rotation return vector3( x * oneoversinthetaover2, y * oneoversinthetaover2, z * oneoversinthetaover2. We use a nonmember function so we can. // pass quaternion expressions as operands without having "funky syntax" // see 10. 4. 10 float dotproduct(const quaternion &a, const quaternion &b) { return a. w*b. w + a. x*b. x + a. y*b. y + a. z*b. z; Quaternion slerp(const quaternion &q0, const quaternion &q1, float t) { // check for out-of range parameter and return edge points if so if (t <= 0. 0f) return q0; if (t >= 1. 0f) return q1; // compute "cosine of angle between quaternions" using dot product. // represent the same rotation, but may produce. We chose q or q to rotate using.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers