TABLE OF CONTENTS


rmnlib/window clipper [ package ]

[ Top ] [ package ]

Synopsis

 soit un groupe de 3 points P0(x0,y0), P1(x1,y1), P2(x2,y2)

 un peu de geometrie basee sur les relations entre "triangles semblables"

                     (x1,y1)*---------*(x0,y1)                  *(X1,Y1)
                             \        |                        /|
                              \       |                       / |
                               \      |                      /  |
             ymax  +------------*-----*--------------------+/   |
                   |      (x2,y2)\    |(x0,y2)      (X2,Y2)*----*(X1,Y2)
                   |              \   |                   /|    |
                   |               \  |                  / |    |
                   |                \ |                 /  |    |
                   |                 \|                /   |    |
                   |                  *(x0,y0)        /    |    |
                   |                                 /     |    |
                   |                         (X0,Y0)*------*----*(X1,Y0)
                   |                                       |(X2,Y0)
                   |                                       |
                   |                                       |
                   |                                       |
                   |                                       |
             ymin  +---------------------------------------+
                   xmin                                 xmax

  pour le segment de droite (x0,y0) ---> (x1,y1)   P0 ----> P1

  point d'intersection (x2,y2): (intersection avec y = constante)

                 y2 = constante y (ymin ou ymax)

                 (x1-x0)   (y1-y0)
                 ------- = -------
                 (x2-x0)   (y2-y0)  (y2 = ymax ou ymin selon le cas)

         donc    x2 = x0 + (x1-x0)/(y1-y0) * (y2-y0)

  pour le segment de droite (X0,Y0) ---> (X1,Y1)

  point d'intersection (X2,Y2): (intersection avec x = constante)

                 X2 = constante x (xmin ou xmax)

                 (X1-X0)   (Y1-Y0)
                 ------- = -------
                 (X2-X0)   (Y2-Y0)  (X2 = xmax ou xmin selon le cas)

         donc    Y2 = Y0 + (Y1-Y0)/(X1-X0) * (X2-X0)

 recette:

 (x2,y2) = (x1,y1) , on suppose que (x2,y2) est dans la fenetre

 si le point (x1,y1) est au "nord" ou au "sud" de la fenetre
   on calcule l'intersection (x2,y2) (y2 = ymin ou ymax)

 si x2 est a l'exterieur de l'intervalle xmin --- xmax
   on passe au cas "est" ou "ouest"
   on calcule l'intersection (x2,x2)  (x2 = xmin ou xmax)

 et dans ce cas, on est sur que y2 sera dans l'intervalle (ymin --- ymax)

rmnlib/boundary_clip_coord_1 [ Functions ]

[ Top ] [ Functions ]

Synopsis

   clip boundaries, one point, using coordinates and a window
   point p0 is assumed to be within the clipping window
   point p1 may be inside or outside of the clipping window
   point p2 will be
   - the intersection of the P0->P1 segment with the clipping window
   - the same as P1 if P1 is inside the clipping window

   p0, p1, p2 are real arrays of dimension 2. 
   the first element is the x coordinate
   the second element is the y coordinate

   l is a real array of dimension 4
   [ xmin, xmax, ymin, ymax]

   the functions returns .true. if clipping was necessary, .false. otherwise

ARGUMENTS

function boundary_clip_coord_1(p0,p1,p2,l) result(clipped) BIND(C,name='BoundaryClipCoord1')
  use ISO_C_BINDING
  implicit none
  real, dimension(2), intent(IN)  :: p0   ! ASSUMED to be inside the window defined by l
  real, dimension(2), intent(IN)  :: p1   ! point to check
  real, dimension(2), intent(OUT) :: p2   ! clipped output
  real, dimension(4), intent(IN) :: l     ! window used to clip p0 -> p1 segment
  logical :: clipped                      ! .true. if clipping occurred

rmnlib/boundary_clip_coord_2n [ Functions ]

[ Top ] [ Functions ]

Synopsis

   clip boundaries, multiple points, using coordinates and a window
   point p0 is assumed to be within the clipping window
   point p1 may be inside or outside of the clipping window
   point p2 will be
   - the intersection of the P0->P1 segment with the clipping window
   - the same as P1 if P1 is inside the clipping window

   p0, p1, p2 are real arrays of dimension (2,n). 
   element (1,i) is the x coordinate of point i
   element (2,i) is the y coordinate of point i

   clipped is an array of dimension (n)
   clipped(i) is .true. if p0(i)->p1(i) needed to be clipped

   l is a real array of dimension 4
   [ xmin, xmax, ymin, ymax]

ARGUMENTS

subroutine boundary_clip_coord_2n(p0,p1,p2,l,clipped,n) BIND(C,name='BoundaryClipCoord2n')
  use ISO_C_BINDING
  implicit none
  real, dimension(2,n), intent(IN)  :: p0   ! ASSUMED to be inside the window defined by l
  real, dimension(2,n), intent(IN)  :: p1   ! point to check
  real, dimension(2,n), intent(OUT) :: p2   ! intersection with clipping window
  real, dimension(4), intent(IN) :: l       ! window used to clip p0 -> p1 segment
  integer, intent(IN) :: n                  ! number of points
  logical, dimension(N) :: clipped          ! .true. if clipping occurred

rmnlib/boundary_clip_coord_n2 [ Functions ]

[ Top ] [ Functions ]

Synopsis

   clip boundaries, multiple points, using coordinates and a window
   point p0 is assumed to be within the clipping window
   point p1 may be inside or outside of the clipping window
   point p2 will be
   - the intersection of the P0->P1 segment with the clipping window
   - the same as P1 if P1 is inside the clipping window

   p0, p1, p2 are real arrays of dimension (n,2). 
   element (i,1) is the x coordinate of point i
   element (i,2) is the y coordinate of point i

   clipped is an array of dimension (n)
   clipped(i) is .true. if p0(i)->p1(i) needed to be clipped

   l is a real array of dimension 4
   [ xmin, xmax, ymin, ymax]

ARGUMENTS

subroutine boundary_clip_coord_n2(p0,p1,p2,l,clipped,n) BIND(C,name='BoundaryClipCoordn2')
  use ISO_C_BINDING
  implicit none
  real, dimension(n,2), intent(IN)  :: p0   ! ASSUMED to be inside the window defined by l
  real, dimension(n,2), intent(IN)  :: p1   ! point to check
  real, dimension(n,2), intent(OUT) :: p2   ! intersection with clipping window
  real, dimension(4), intent(IN) :: l       ! window used to clip p0 -> p1 segment
  integer, intent(IN) :: n                  ! number of points
  logical, dimension(N) :: clipped          ! .true. if clipping occurred