Raycast plane

To Raycast against a plane we must find a point which is on the plane being cast against and also along the normal of the ray. We know a point is on the surface of a plane if it satisfies the plane equation. If no point along the ray satisfies the plane equation, the ray and plane do not intersect:

Raycast plane

Getting ready

We are going to implement a function that performs a Raycast against a plane. This function will return t, the time along the ray at which it intersects the plane. If there is no intersection, the value of t will be negative.

How to do it…

Follow these steps to implement raycasting against a plane:

  1. Declare the Raycast function in ...

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.