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

Added 11l
(Added 11l)
Line 6:
 
Find the point of intersection for the infinite ray with direction (0,-1,-1) passing through position (0, 0, 10) with the infinite plane with a normal vector of (0, 0, 1) and which passes through [0, 0, 5].
 
=={{header|11l}}==
 
<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)
 
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>
 
{{out}}
<pre>
The ray intersects the plane at (0, -5, 5)
</pre>
 
=={{header|C}}==
1,481

edits