Quaternions. Paul Taylor 2010. Swizzle. What is a swizzle?. Matrix Rotations. A simple 2D ( xy ) Rotation Matrix: Rotates in the xy plane counterclockwise by Ɵ Degrees ( In a RH Space) The Determinant is always 1. http://en.wikipedia.org/wiki/Rotation_matrix. 3D Rotations.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Paul Taylor 2010
Pros: Easy to visualise
Cons: Gimbal Lock
If any one axis is exactly 0 or PI or –PI
(Where Cos Ɵ = 1 and Sin Ɵ = 0)
The freedom of rotation is limited to a plane.
Q Quaternion is a 4-tuple of numbers, typically called (s, x, y, z)
S acts as a scalar, and xyz act as a 3D vector
The vector xyz should satisfy
X2 + Y2 + Z2 = XYZ = -1
Where s2 + X2 + Y2 + Z2 = 1 the quaternion can be considered a rotation.
Matrix must be at minimum 3x3 typically stored as a 4x4.
A quaternion may be stored as 4 values.
Chaining (preparing) an xyz rotation:
“the radiant intensity observed from a "Lambertian" surface is directly proportional to the cosine of the angle θ between the observer's line of sight and the surface normal.” - Wikipedia
We generate a vector from the surface point to the eye:
toEye = view – vertex.position;
toEye = Normalize(toEye);
specularPower = vertex.specular.a // a = power
// Minimum of 1.0f
specularPower = max(specularPower, 1.0f);
Float3 reflection = reflect(light.vector, vertex.normal);
specularFactor = dot(reflection, toEye);
// No specular if light is behind
specularFactor = max(specularFactor, 0.0f);
// Now we add the exponent
specularFactor = pow(specularFactor, specularPower);
light += specularFactor * vertex.specular* light.specular;