Find the intersection of a line with a plane: Difference between revisions

Content added Content deleted
Line 10: Line 10:


<lang 11l>F intersection_point(ray_direction, ray_point, plane_normal, plane_point)
<lang 11l>F intersection_point(ray_direction, ray_point, plane_normal, plane_point)
return ray_point - ray_direction * dot(ray_point - plane_point, plane_normal) / dot(ray_direction, plane_normal)
R ray_point - ray_direction * dot(ray_point - plane_point, plane_normal) / dot(ray_direction, plane_normal)


print(‘The ray intersects the plane at ’intersection_point((0.0, -1.0, -1.0), (0.0, 0.0, 10.0), (0.0, 0.0, 1.0), (0.0, 0.0, 5.0)))</lang>
print(‘The ray intersects the plane at ’intersection_point((0.0, -1.0, -1.0), (0.0, 0.0, 10.0), (0.0, 0.0, 1.0), (0.0, 0.0, 5.0)))</lang>