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

Content deleted Content added
Tikkanz (talk | contribs)
→‎{{header|J}}: formatting
Tikkanz (talk | contribs)
Line 185: Line 185:
=={{header|J}}==
=={{header|J}}==
'''Solution:'''
'''Solution:'''
<lang j>mp=: +/ .* NB. matrix product
<lang j>mp=: +/ .* NB. matrix product
p=: mp&{: %~ -&{. mp {:@] NB. solve
p=: mp&{: %~ -~&{. mp {:@] NB. solve
intersectLinePlane=: {.@[ - {:@[ * p NB. substitute</lang>
intersectLinePlane=: [ +/@:* 1 , p NB. substitute</lang>
'''Example Usage:'''
'''Example Usage:'''
<lang j> Line=: 0 0 10 ,: 0 _1 _1 NB. Point, Ray
<lang j> Line=: 0 0 10 ,: 0 _1 _1 NB. Point, Ray