Raycast Sphere
Given a ray with origin o, indirection d and a sphere with origin c and radius r; we want to check if the ray ever intersects the sphere:
If the ray intersects the sphere, this intersection will happen at some distance along the ray. Within the context of ray casting, we often assume it takes one second to travel one unit along the ray. Because of this, distance and time are often used interchangeably.
Because of this ambiguity with the vocabulary, many resources might say that the ray intersects the sphere at some time, t. If the ray does not intersect the sphere, t is undefined.
Getting ready
We are going to implement a function to ...
Get Game Physics Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.