Understanding Ray-Sphere Intersection and Quaternions in 4D Vector Space
This document explores the method of intersecting a ray with a bounding sphere using the float intersectRaySphere function. It explains the mathematical computation behind ray-sphere intersection, utilizing geometric properties like dot products and square roots. The second part delves into quaternions, their significance in 4-dimensional vector space, and their advantages over traditional rotation methods, such as avoiding gimbal lock. Quaternions require only four components to represent 3D rotations, making them efficient and practical for computations in computer graphics and robotics.
Understanding Ray-Sphere Intersection and Quaternions in 4D Vector Space
E N D
Presentation Transcript
Intersecting a Bounding Sphere • float intersectRaySphere(Ray ray,Sphere sphere) { Vecdst = ray.o - sphere.o; Real B = dot(dst,ray.d); Real C = dot(dst,dst) - sphere.r2; Real D = B*B - C; return D > 0 ? - B - sqrt(D) : std::numeric_limits<float>::infinity(); }
What are Quaternions? • An element of the 4-Dimensional vector-space
Why do you need quaternions? • No Gimbal Lock • They only require 4 numbers, to represent the equiv. of a 3x3 Matrix (9 Numbers) • Angle / Axis conversions are simple • Normalising Quaternions vs. Orthogonalising Matrices • Multiplicative like matrices
What a Quaternion looks like • w + xi + yj + zk (i, j, and k are imaginary numbers)