Exercise 1: Building and Testing a 180° Quaternion Around the Y-Axis — Possible Solution ==================================================================== BUILDING THE QUATERNION ------------------------------ Using this chapter's own formula, q = (cos(theta/2), ax*sin(theta/2), ay*sin(theta/2), az*sin(theta/2)), for theta=180 degrees around the y-axis (axis = (0,1,0)): half-angle = 90 degrees cos(90 deg) = 0 (verified in floating point as approximately 6.12*10^-17, not exactly 0 - the same floating-point approximation of pi verified back in Chapter 2) sin(90 deg) = 1 q = (0, 0*1, 1*1, 0*1) = (0, 0, 1, 0) ROTATING (0,0,1) ------------------------------ Applying the rotation formula v' = q*v*q^-1 to v=(0,0,1) with this quaternion gives the result (0, 0, -1). CONFIRMING AGAINST THE Ry(180°) MATRIX ------------------------------ Chapter 6's Ry(theta) matrix is: [[cos theta, 0, sin theta], [0, 1, 0], [-sin theta, 0, cos theta]] At theta=180 degrees, cos(180)=-1 and sin(180)=0 (approximately, per the same floating-point caveat), so: Ry(180) = [[-1,0,0],[0,1,0],[0,0,-1]] Applying this matrix to (0,0,1): Ry(180) * (0,0,1) = (-1*0+0*0+0*1, 0*0+1*0+0*1, 0*0+0*0+(-1)*1) = (0, 0, -1) This matches the quaternion result exactly: (0, 0, -1) both ways. WHY THIS RESULT MAKES GEOMETRIC SENSE ------------------------------ Rotating the point (0,0,1) - directly "in front" along the z-axis - by a full 180 degrees around the y-axis should flip it to point directly "behind," at (0,0,-1), while leaving the y-coordinate untouched (since rotation around an axis never moves points along that same axis, and here the point had no y-component to begin with anyway). Both computations agree with this straightforward geometric expectation. WHY THIS WORKS AS AN ANSWER ------------------------------ The answer constructs the quaternion using this chapter's own exact formula, applies the rotation, and independently re-derives the same result using the Chapter 6 rotation matrix, confirming the two representations agree exactly rather than simply asserting they should.