clip_polygon Subroutine

public pure subroutine clip_polygon(px, py, lo, hi, cx, cy, m)

Sutherland-Hodgman clip of the closed polygon (px, py) to [lo(1),hi(1)] x [lo(2),hi(2)]. Non-finite vertices are dropped first. On return (cx(1:m), cy(1:m)) is the clipped polygon; m = 0 when fewer than three vertices remain. cx, cy need clip_polygon_capacity(size(px)) elements. A vertex created on an edge lies exactly on it.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: px(:)
real(kind=wp), intent(in) :: py(:)
real(kind=wp), intent(in) :: lo(2)
real(kind=wp), intent(in) :: hi(2)
real(kind=wp), intent(out) :: cx(:)
real(kind=wp), intent(out) :: cy(:)
integer, intent(out) :: m