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

Module cg

source code

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

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

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

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

_distanceToPlane(a, plane)

source code 
Compute the value(s) proportional to 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 value(s) proportional to the L2 distance(s)
alpha : double
a value representing the proportion, divide the value(s) by this number to get the L2 distance(s)

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)