jicgeometry

Module for geometric operations.

The module contains two classes to perform geometric operations in 2D and 3D space:

A 2D point can be generated using a pair of x, y coordinates.

>>> p1 = Point2D(3, 0)

Alternatively, a 2D point can be created from a sequence.

>>> l = [0, 4]
>>> p2 = Point2D(l)

The x and y coordinates can be accessed as properties or by their index.

>>> p1.x
3
>>> p1[0]
3

Addition and subtraction result in vector arithmetic.

>>> p1 + p2
<Point2D(x=3, y=4, dtype=int)>
>>> p1 - p2
<Point2D(x=3, y=-4, dtype=int)>

Scalar multiplication is supported.

>>> (p1 + p2) * 2
<Point2D(x=6, y=8, dtype=int)>

Scalar division uses true division and as a result always returns a 2D point of dtype float.

>>> p1 / 2
<Point2D(x=1.50, y=0.00, dtype=float)>

It is possible to calculate the distance between two points.

>>> p1.distance(p2)
5.0

Points can also be treated as vectors.

>>> p3 = p1 + p2
>>> p3.unit_vector
<Point2D(x=0.60, y=0.80, dtype=float)>
>>> p3.magnitude
5.0
class jicgeometry.Point2D(a1, a2=None)

Class representing a point in 2D space.

astuple()

Return the x, y coordinates as a tuple.

astype(dtype)

Return a point of the specified dtype.

distance(other)

Return distance to the other point.

dtype

Return the type of the x, y coordinates as a string.

magnitude

Return the magnitude when treating the point as a vector.

unit_vector

Return the unit vector.

class jicgeometry.Point3D(a1, a2=None, a3=None)

Class representing a point in 3D space.

astuple()

Return the x, y coordinates as a tuple.

astype(dtype)

Return a point of the specified dtype.

distance(other)

Return distance to the other point.

dtype

Return the type of the x, y coordinates as a string.

magnitude

Return the magnitude when treating the point as a vector.

unit_vector

Return the unit vector.