Geometry Tools

geotools.cross(Vector a, Vector b) → Vector

Cross product

geotools.distance(Point u, Point v) → double

Compute distance between 2 points.

geotools.dot(Vector a, Vector b) → double

Dot product

geotools.isParallell(Vector v1, Vector v2) → int

Return 1 if parallell, -1 if anti-parallell and 0 if not parallell.

geotools.isPerpendicular(Vector v1, Vector v2) → int

Return 1 if perpendicular and 0 if not perpendicular.

geotools.perpendicular(Vector v) → Vector

Create a vector perpendicular to v

AABBox

class geotools.AABBox

AABBox(min=(-0.5, -0.5, -0.5), max=(0.5, 0.5, 0.5))

Class representing an Axis Aligned Bounding Box

static __new__(S, ...) → a new object with type S, a subtype of T
addPoint(self, pnt)

Adjust bounds to include point.

addPoints(self, pnts)

Adjust bounds to include point.

invalidate(self)

Set bounding box in invalid state.

isPointIn(self, pnt, int strictlyIn=False) → int

Check if point is inside box.

isValid(self) → int

Check validity

static union(type cls, AABBox a, AABBox b)

Return a new bounding box which is a union of the arguments.

__eq__

x.__eq__(y) <==> x==y

__ge__

x.__ge__(y) <==> x>=y

__gt__

x.__gt__(y) <==> x>y

__init__

x.__init__(...) initializes x; see help(type(x)) for signature

__le__

x.__le__(y) <==> x<=y

__lt__

x.__lt__(y) <==> x<y

__ne__

x.__ne__(y) <==> x!=y

__repr__

Return string representation of a box.

__str__

Return string representation of a box.

center

Calculate center of box

diagonal

Return diagonal as a vector

max

max: geotools.Point

min

min: geotools.Point

radius

Return radius of the sphere enclosing the box

volume

Calculate volume of box

Camera

class geotools.Camera

Camera(projection=PARALLEL)

Modify the loc, dir & up variables and then call updateFrame to set the up the camera frame vectors.

Projection :PARALLEL or PROJECTED projection type
Loc :camera location
Dir :from camera towards view (nonzero and not parallel to up)
Up :(nonzero and not parallel to dir)
X :camera frame X vector
Y :camera frame Y vector
Z :camera frame Z vector
Target :fixed point used in camera rotations and camera dolly operations.
static __new__(S, ...) → a new object with type S, a subtype of T
getDollyVector(self, int x0, int y0, int x1, int y1, double distance_to_camera) → Vector

Get camera dolly vector for the given screen coordinates

pan(self, int lastx, int lasty, int x, int y, Point target=None)

Pan camera due to mouse motion.

rotate(self, double angle, Vector axis, Point center=None)

Rotate camera and update frame.

rotateDeltas(self, double dx, double dy, double speed=400, Point target=None)

Rotate camera according to dx, dy mouse motion.

setAngle(self, double angle)
setBackView(self)
setBottomView(self)
setFrontView(self)
setFrustumAspect(self, double frustum_aspect)

setFrustumAspect() changes the larger of the frustum’s widht/height so that the resulting value of width/height matches the requested aspect. The camera angle is not changed. If you change the shape of the view port with a call setViewportSize(), then you generally want to call SetFrustumAspect().

setFrustumNearFar(self, double n, double f)
setIsoView(self)
setLeftView(self)
setRightView(self)
setTopView(self)
setViewportSize(self, int width, int height)

Location of viewport in pixels. These are provided so you can set the port you are using and get the appropriate transformations to and from screen space.

updateFrame(self)
zoomExtents(self, Point near, Point far, double angle=<???>)
zoomFactor(self, double magnification_factor, fixed_screen_point=None)
X

X: geotools.Vector

Y

Y: geotools.Vector

Z

Z: geotools.Vector

__init__

x.__init__(...) initializes x; see help(type(x)) for signature

dir

dir: geotools.Vector

fvBottom

fvBottom: ‘double’

fvFar

fvFar: ‘double’

fvLeft

fvLeft: ‘double’

fvNear

fvNear: ‘double’

fvRight

fvRight: ‘double’

fvTop

fvTop: ‘double’

loc

loc: geotools.Point

projection

projection: ‘int’

scrBottom

scrBottom: ‘int’

scrFar

scrFar: ‘double’

scrLeft

scrLeft: ‘int’

scrNear

scrNear: ‘double’

scrRight

scrRight: ‘int’

scrTop

scrTop: ‘int’

target

target: geotools.Point

up

up: geotools.Vector

Plane

class geotools.Plane

Plane(origin=<???>, xaxis=<???>, yaxis=<???>)

Class representing a mathematical infinite plane.

ValueAt(self, pnt) → double
closestPoint(self, pnt) → Point

Return closest point on plane

distanceTo(self, pnt) → double

Signed distance from plane to pnt

flip(self)

Flip direction of normal

static fromFrame(cls, origin, xaxis, yaxis)
static fromNormal(cls, origin, normal)
intersectLine(self, start, end)

Find intersection with line defined by the points start and end

transform(self, Transform trans)

Transform plane

a

a: ‘double’

b

b: ‘double’

c

c: ‘double’

d

d: ‘double’

origin

origin: geotools.Point

xaxis

xaxis: geotools.Vector

yaxis

yaxis: geotools.Vector

zaxis

zaxis: geotools.Vector

Point

class geotools.Point

Point(*args)

Class representing a 3D point in space

static __new__(S, ...) → a new object with type S, a subtype of T
distanceTo(self, Point arg) → double

Compute distance between 2 points.

isZero(self) → int

Check if arg is all zeros.

maximumCoordinate(self) → double
maximumCoordinateIndex(self) → int
set(self, *args)

Set one or more coordinates. accept both multiple argument and sequence like arguments.

__abs__

Return absolute value of point: abs(v)

__add__

Point addition The arguments must be of same length

__div__

Point division by scalar.

__eq__

x.__eq__(y) <==> x==y

__ge__

x.__ge__(y) <==> x>=y

__getitem__

Override the list __getitem__ function to return a new point rather than a list.

__gt__

x.__gt__(y) <==> x>y

__iadd__

Inline Point addition ( p1 += p2) The arguments must be of same length

__idiv__

Inline Point division by scalar. (p1 /= 2.)

__imul__

Inline Point multiplication (v1 *= s1) We accept multiplication by scalar and a 4x4 transformation matrix.

__init__

We accept both multiple argument and sequence like arguments.

__isub__

Inline Point subtraction ( p1 -= p2) The arguments must be of same length

__le__

x.__le__(y) <==> x<=y

__len__

Length of sequence

__lt__

x.__lt__(y) <==> x<y

__mul__

Point multiplication We accept multiplication by a scalar, and a 4x4 transformation matrix.

__ne__

x.__ne__(y) <==> x!=y

__neg__

Return negated value of point: -v

__pos__

Return positive value of point: +v

__radd__

x.__radd__(y) <==> y+x

__rdiv__

x.__rdiv__(y) <==> y/x

__repr__

Return string representation of a point.

__rmul__

x.__rmul__(y) <==> y*x

__rsub__

x.__rsub__(y) <==> y-x

__str__

Return string representation of a point.

__sub__

Point subtraction The arguments must be of same length

x

x: ‘double’

y

y: ‘double’

z

z: ‘double’

Quaternion

class geotools.Quaternion

Quaternion(*args)

Class representing a quaternion usefull for rotation transformations.

static __new__(S, ...) → a new object with type S, a subtype of T
conj(self) → Quaternion
static fromAngleAxis(type cls, double angle, Vector axis)
imap(self, *args)

Inverse rotation. We accept point as multiple argument, sequence like arguments and sequence of multiple points.

map(self, *args)

Rotation. We accept point as multiple argument, sequence like arguments and sequence of multiple points.

set(self, *args)

Set one or more coordinates. accept both multiple argument and sequence like arguments.

unit(self) → Quaternion
__getitem__

x.__getitem__(y) <==> x[y]

__imul__

x.__imul__(y) <==> x*=y

__init__

We accept both multiple argument and sequence like arguments.

__len__

Length of sequence

__mul__

x.__mul__(y) <==> x*y

__repr__

Return string representation of a Quaternion.

__rmul__

x.__rmul__(y) <==> y*x

__str__

Return string representation of a Quaternion.

length

Calculate lenght of Quaternion

lengthSquared

Calculate squared lenght of Quaternion

transform

create the coresponding transformation matrix

w

w: ‘double’

x

x: ‘double’

y

y: ‘double’

z

z: ‘double’

Transform

class geotools.Transform

Transform(*args)

Matrix of 4x4 size. Typical 3D transformation matrix.

static __new__(S, ...) → a new object with type S, a subtype of T
cameraToClip(self, Camera cam)
cameraToWorld(self, Camera cam) → Transform
clipToCamera(self, Camera cam)
det(self) → double

Determinand of matrix

identity(self) → Transform

set identity matrix

invert(self) → Transform

Inverse of matrix

map(self, *args)

We accept point as multiple argument, sequence like arguments and sequence of multiple points.

rotateAxisCenter(self, double angle, _axis, _center=(0.0, 0.0, 0.0)) → Transform

Construct 4x4 rotation matrix.

rotateX(self, double x) → Transform

We accept both multiple argument and sequence like arguments.

rotateY(self, double y) → Transform

We accept both multiple argument and sequence like arguments.

rotateZ(self, double z) → Transform

We accept both multiple argument and sequence like arguments.

scale(self, *args)

We accept both multiple argument and sequence like arguments.

set(self, *args)

We accept 16 arguments setting all values. Sequence of sequence of size 3x3 setting all values.

m11 m12 m13 m14
Matrix = m21 m22 m23 m24
m31 m32 m33 m34 m41 m42 m43 m44
translate(self, *args)

We accept both multiple argument and sequence like arguments.

transpose(self) → Transform

Transpose of matrix

worldToCamera(self, Camera cam) → Transform
zero(self) → Transform

set all values to zero

__abs__

Return absolute value of matrix: abs(m)

__add__

Matrix addition They must be of same shape.

__div__

Matrix division We accept only division by a scalar.

__getitem__

Return rows as a tuple object

__iadd__

Inline Matrix addition ( m1 += m2) They must be of same shape.

__idiv__

Inline Matrix division (v1 *= v2) We accept only division by a scalar.

__imul__

Matrix multiplication We accept both multiplication by a scalar and a other matrix. This is the matrix multiplication known from linear algebra.

__init__

We accept 16 arguments setting all values. Sequence of sequence of size 3x3 setting all values.

m11 m12 m13 m14
Matrix = m21 m22 m23 m24
m31 m32 m33 m34 m41 m42 m43 m44
__isub__

Inline Matrix subtraction ( m1 -= m2) They must be of same shape.

__len__

We have 4 rows

__mul__

Matrix multiplication We accept both multiplication by a scalar and a other matrix. This is the matrix multiplication known from linear algebra. See the Matrix.dot function for this.

__neg__

Return negated value of matrix: -v

__pos__

Return positive value of matrix: +v

__radd__

x.__radd__(y) <==> y+x

__rdiv__

x.__rdiv__(y) <==> y/x

__repr__

Return string representation of a matrix.

__rmul__

x.__rmul__(y) <==> y*x

__rsub__

x.__rsub__(y) <==> y-x

__str__

Return string representation of a matrix.

__sub__

Matrix subtraction They must be of same shape.

Vector

class geotools.Vector
distanceTo(self, Point arg) → double

Compute distance between 2 points.

isZero(self) → int

Check if arg is all zeros.

maximumCoordinate(self) → double
maximumCoordinateIndex(self) → int
set(self, *args)

Set one or more coordinates. accept both multiple argument and sequence like arguments.

unit(self) → Vector

Normalize the vector (arg.lenght = 1.)

length

Calculate lenght of vector

lengthSquared

Calculate squared lenght of vector

x

x: ‘double’

y

y: ‘double’

z

z: ‘double’

Table Of Contents

Previous topic

geotools documentation

This Page