geom Package

geom Package

Geometry package

matrix Module

class gloopy.geom.matrix.Matrix(position=None, orientation=None)[source]

Bases: object

4x4 matrix. Supports iteration over elements.

__init__(self, position=None, orientation=None)[source]

Creates a matrix representing the given orientation and offset.

transform(vert)[source]

Return a new Vector equal to vert transformed by this matrix (i.e. rotated by our orientation and translated by our position.)

orientation Module

class gloopy.geom.orientation.Orientation(forward=None, up=None)[source]

Bases: object

Defines an orientation by maintaining a forward and up vector (and a derived right, orthogonal to both.)

__init__(forward=None, up=None)[source]

Constructs an orientation looking along the forward vector. If none is given then defaul to the negative Z axis.

If up is specified, it must lie at right angles to forward. If none is given then a default is chosen, the vector at right angles to forward which lies closest to the positive Y axis.

Orientation.Identity, which results in zero rotation, is with forward pointing along the negative Z axis, up along the positive Y axis (and hence right along the positive X axis.)

Identity = Orientation(Vector(0, 0, -1), up=Vector(0, 1, -6.1e-17))
static Random()[source]

Return a new random Orientation

forward

The forward vector

matrix[source]

The matrix that the OpenGL modelview matrix should be multiplied by to represent this orientation. It’s likely that this method will disappear in later releases of Gloopy.

pitch(angle)[source]

Rotate about the ‘right’ axis (ie. +ve angle pitches up.)

roll(angle)[source]

Rotate new Orientation, rotated about the ‘forward’ axis (ie. +ve angle rolls to the right.)

rotate(axis, angle)[source]

Rotate about the given axis by the given angle.

up

The up vector

yaw(angle)[source]

Rotate about the ‘down’ axis (ie. +ve angle yaws to the right.)

gloopy.geom.orientation.matrix_type

alias of c_float_Array_16

vector Module

class gloopy.geom.vector.Vector[source]

Bases: gloopy.geom.vector.VectorBase

3-component named tuple: (x, y, z), with some methods, including value type equality semantics.

__init__(x, y, z)

Arithmetic operators are supported:

__neg__(): unary minus to invert direction
__add__(other): addition of vector or 3-tuple
__sub__(other): subtraction of vector or 3-tuple
__mul__(float): scale a vector
__div__(float): scale a vector (truediv also supported)
COMPONENTS = 3
Origin = Vector(0, 0, 0)
static RandomCube(size, ints=False)[source]

A new random Vector, evenly distributed within a cube of size sides.

static RandomShell(radius)[source]

A new random Vector, evenly distributed on surface a sphere of radius.

static RandomSphere(radius)[source]

A new random Vector, evenly distributed within a sphere of radius.

XAxis = Vector(1, 0, 0)
XNegAxis = Vector(-1, 0, 0)
YAxis = Vector(0, 1, 0)
YNegAxis = Vector(0, -1, 0)
ZAxis = Vector(0, 0, 1)
ZNegAxis = Vector(0, 0, -1)
angle(other)[source]

return the angle between this vector and the given one

any_orthogonal()[source]

Return any unit vector at right angles to the given vector

cross(other)[source]

Return a new vector, the cross product a x b = (a2b3 - a3b2, a3b1 - a1b3, a1b2 - a2b1) http://en.wikipedia.org/wiki/Cross_product

dot(other)[source]

Return the scalar dot product

length[source]
length2[source]

Length squared. Cheaper to calculate.

normalized(length=1)[source]

Return a new vector in the same direction, but given length (default 1)

rotate(axis, angle)[source]

Return a new vector, rotated about the given axis

If rotating many verts around the same axis, consider creating a Matrix to represent the rotation instead, and calling m.transform(v) on each vertex, which might be faster.

Table Of Contents

Previous topic

gloopy Package

Next topic

tests Package

This Page