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

Content deleted Content added
Added Haskell
Added MatLab
Line 307: Line 307:
The ray intersects the plane at (0.0, -5.0, 5.0)
The ray intersects the plane at (0.0, -5.0, 5.0)
</pre>
</pre>

=={{header|MATLAB}}==
{{trans|Kotlin}}
<lang MATLAB>function point = intersectPoint(rayVector, rayPoint, planeNormal, planePoint)

pdiff = rayPoint - planePoint;
prod1 = dot(pdiff, planeNormal);
prod2 = dot(rayVector, planeNormal);
prod3 = prod1 / prod2;

point = rayPoint - rayVector * prod3;</lang>
{{out}}
<lang MATLAB>>> intersectPoint([0 -1 -1], [0 0 10], [0 0 1], [0 0 5])

ans =

0 -5 5
</lang>


=={{header|Perl 6}}==
=={{header|Perl 6}}==