Package pycv :: Package cs :: Package cg
[hide private]
[frames] | no frames]

Package cg

source code

An umbrella package containing all Computational Geometry packages.



Submodules [hide private]

Functions [hide private]
 
isInsidePoly(x, y, poly)
Check if point (x,y) is inside a polygon or not.
source code
 
poly_info(poly)
Compute the area of a polygon.
source code
 
distanceToPlane(a, plane)
Compute the L2 distance(s) of a point or a set of points to a plane.
source code
 
smallestEnclosingBall(a)
Compute a (hyper-)ball of smallest radius enclosing a point set.
source code
Variables [hide private]
  __doc__
Function Details [hide private]

isInsidePoly(x, y, poly)

source code 

Check if point (x,y) is inside a polygon or not.

Input:
x: x location y: y location poly: a numpy array of shape (N,2) representing a polygon
Output:
1 if (x,y) is inside the polygon, 0 otherwise.
Reference:
  1. Randolph Franklin (WRF) at

    http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

poly_info(poly)

source code 
Compute the area of a polygon.

Input:
    poly: a numpy array of shape (N,2) representing a polygon
Output:
    (x, y) : centroid location
    area : area of the polygon
    direction : direction to differentiate between clockwise and 
        counter-clockwise

distanceToPlane(a, plane)

source code 
Compute the L2 distance(s) of a point or a set of points to a plane.
Parameters:
  • a (array(shape=(*,d), dtype='d')) - a point or a set of points in a d-dimensional space
  • plane (array(shape=(d+1,), dtype='d')) -
    a set of parameters representing the plane
    i.e. a0*x0 + a1*x1 + ... + a_{d-1}*x_{d-1} + a_d = 0
Returns:
b : array(shape=(*), dtype ='d')
a value or a set of values representing the L2 distance(s)

smallestEnclosingBall(a)

source code 

Compute a (hyper-)ball of smallest radius enclosing a point set.

Reference:
This is a re-implementation from scratch based on the idea of Bernd Gaertner at http://www.inf.ethz.ch/personal/gaertner by Minh-Tri Pham
Parameters:
  • a (array(shape=(N,d), dtype='d')) - an array of N d-dimensional points
Returns:
p : array(shape=(d,), dtype='d')
center point of the (hyper-)ball
r : double
its squared radius, supposed to be the smallest possible value
support_array : array(shape=(M,d), dtype='d')
an array of supporting points, M is the number of supporting points
accuracy : double
relative accuracy of the solution
slack : double
slack value