class Line {
has $.P0;
has $.u⃗;
}
class Plane {
has $.V0;
has $.n⃗;
}
sub infix:<∙> ( @a, @b where +@a == +@b ) { [+] @a «*» @b }
sub line-plane-intersection ($𝑳, $𝑷) {
my $cos = $��.n⃗ ∙ $��.u⃗;
return 'Vectors are orthogonal; no intersection or line within plane'
if $cos == 0;
my $�� = $��.P0 «-» $��.V0;
my $S𝐼 = -($��.n⃗ ∙ $��) / $cos;
$�� «+» $S𝐼 «*» $��.u⃗ «+» $��.V0;
}
say 'Intersection at point: ', line-plane-intersection(
Line.new( :P0(0,0,10), :u⃗(0,-1,-1) ),
Plane.new( :V0(0,0, 5), :n⃗(0, 0, 1) )
);
Output:
Intersection at point: (0 -5 5)