Calculates the intersection of a line and a plane
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=Float64), | intent(in), | dimension(3) | :: | l0 | Point on line |
|
real(kind=Float64), | intent(in), | dimension(3) | :: | l | Ray of line |
|
real(kind=Float64), | intent(in), | dimension(3) | :: | p0 | Point on plane |
|
real(kind=Float64), | intent(in), | dimension(3) | :: | n | Normal vector of plane |
|
real(kind=Float64), | intent(out), | dimension(3) | :: | p | Line-plane intersect point |
|
real(kind=Float64), | intent(out) | :: | t | "time" to intersect |
subroutine line_plane_intersect(l0, l, p0, n, p, t)
!+ Calculates the intersection of a line and a plane
real(Float64), dimension(3), intent(in) :: l0
!+ Point on line
real(Float64), dimension(3), intent(in) :: l
!+ Ray of line
real(Float64), dimension(3), intent(in) :: p0
!+ Point on plane
real(Float64), dimension(3), intent(in) :: n
!+ Normal vector of plane
real(Float64), dimension(3), intent(out) :: p
!+ Line-plane intersect point
real(Float64), intent(out) :: t
!+ "time" to intersect
real(Float64) :: ldotn
ldotn = dot_product(l, n)
if(ldotn.eq.0.0)then
t = 0.0
else
t = dot_product(p0 - l0, n)/ldotn
endif
p = l0 + t*l
end subroutine line_plane_intersect