GeometricbasicsCpp module

Extension written in C++ with basic geometric functions.

geometricbasicsCpp.turn(p, q, r)
Determines whether p, q and r are collinear or form a left or
right turn.

This function counts how many convex r-holes are in points (the point set may be colored). It is an implementation of the algorithm presented in “Searching for Empty Convex Polygons” [1]_

Parameters:

p : list

A point is represented as a list of 3 integers: the

first two are the coordinates of the point, the third

one is the color. The color is optional.

q : Analogous to p

r : Analogous to p

Returns:

t : int

-1 if p, q and r form a left turn, -0 if p, q and r are collinear,

1 if p, q and r form a right turn,

Notes

The coordinates of the points should be less than or equal to \(2^{30}\) to prevent overflow on the C++ side.

Examples

>>> import geometricbasicsCpp as gb
>>> p=[0,0]
    >>> q=[1,0]
    >>> p=[1,1]
>>> gb.turn(p, q, r)
-1

This Page