Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


  >  Docs Center  >  Libraries  >  Motley  >  MGH_POLYCLIP2

MGH_POLYCLIP2

MGH_POLYCLIP2

Name


  MGH_POLYCLIP2

Purpose


  Clip an arbitrary polygon on the X-Y plane to a line of arbitrary
  orientation using the Sutherland-Hodgman algorithm.

Category


  Graphics, Region of Interest, Geometry

Calling Sequence


  result = MGH_POLYCLIP2(clip, poly, COUNT=count)

Return Value


  The function returns the clipped polygon as a [2,n] array. The
  second dimension will equal the value of the COUNT argument, except
  where COUNT is 0 in which case the return value is -1.
  POSITIONAL ARGUMENTS
  poly (input, floating array)
    A [2,m] vector defining the polygon to be clipped.
  clip (input, 3-element numeric vector)
    This parameter describes the line to be clipped to. The polygon is
    clipped to the half-plane (clip[0] x + clip[1] y + clip[2]) < 0.

Keyword Parameters


  COUNT (output, integer)
    The number of vertices in the clipped polygon.

Procedure


  The polygon is clipped using the Sutherland-Hodgman algorithm.
  This function is similar to MGH_POLYCLIP, which was written first
  & clips to vertical or horizontal lines only. It turns out that
  MGH_POLYCLIP2 is competitive with MGH_POLYCLIP in terms of speed
  so the former may supersede the latter.
  Both polygon-clipping functions are based on JD Smith's
  implementation of the Sutherland-Hodgman algorithm in his POLYCLIP
  function. He can take most of the credit and none of the blame.
###########################################################################
  Copyright (c) 2002-2013 NIWA:
  http://www.niwa.co.nz/
  Licensed under the MIT open source license:
  http://www.opensource.org/licenses/mit-license.php
###########################################################################

Modification History


  Mark Hadfield, 2002-08:
    Written.
  Mark Hadfield, 2013-06:
    - The result array is now allocated before looping through the input
      vertices, wherease before it was progressively built up by concatenation.
      This change results in an enormous speed-up for large (> 10,000) polygons.



© 2018 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us