Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | n |
Normal to the circle |
||
type(vector), | intent(in) | :: | p0 |
a centre of the circle |
||
real(kind=wp), | intent(in) | :: | radius |
Radius of the circle |
||
type(vector), | intent(in) | :: | l0 |
origin of the ray |
||
type(vector), | intent(in) | :: | l |
direction vector of the ray |
||
real(kind=wp), | intent(inout) | :: | t |
Distance from l0 to the intersection point |
logical function intersectCircle(n, p0, radius, l0, l, t) ! !> Normal to the circle type(vector), intent(in) :: n !> a centre of the circle type(vector), intent(in) :: p0 !> direction vector of the ray type(vector), intent(in) :: l !> origin of the ray type(vector), intent(in) :: l0 !> Radius of the circle real(kind=wp), intent(in) :: radius !> Distance from l0 to the intersection point real(kind=wp), intent(inout) :: t real(kind=wp) :: d2 type(vector) :: v, p intersectCircle = .false. t = 0._wp if(intersectPlane(n, p0, l0, l, t))then p = l0 + l * t v = p - p0 d2 = v .dot. v if(sqrt(d2) <= radius)intersectCircle=.true. end if end function intersectCircle