Module igeVmath
Vector Math Module.
Functions
def abs(...)
-
compute the absolute value of a vector per element
Forms
vecN = igeVmath.abs(vecN) (N = 2 or 3 or 4)
def add(...)
-
add two vectors or two matrices
Forms
vecN = igeVmath.add(vecN, vecM) matNN = igeVmath.add(matNN, matMM) N,M = 2 or 3 or 4 type of return value is depend on first parameter type
def almostEqual(...)
-
Compare two values and if the difference is smaller than EPSILON, it will be considered identical
Forms
vecN = igeVmath.almostEqual(vecN, vecN) (N = 2 or 3 or 4)
def appendScale(...)
-
append (post-multiply) a scale transformation to a matrix faster than creating and multiplying a scale transformation matrix
Forms
matrix = igeVmath.appendScale(matrix, vector)
def conj(...)
-
compute the conjugate of a quaternion
Forms
quat = igeVmath.conj(quat)
def cross(...)
-
compute cross product of two vectors
Forms
float = igeVmath.cross(vec2, vec2) vec3 = igeVmath.cross(vec3, vec3)
def determinant(...)
-
determinant of a matrix
Forms
scalar = igeVmath.determinant(matrix)
def div(...)
-
division vector by a scalar
Forms
vecN = igeVmath.div(vecN, float) vecN = igeVmath.div(vecN, vecN) division vector per element (N = 2 or 3 or 4)
def dot(...)
-
compute the dot product of two vectors
Forms
float = igeVmath.dot(vecN, vecN) (N = 2 or 3 or 4)
def frustum(...)
-
construct a perspective projection matrix based on frustum
Forms
matrix4 = igeVmath.frustum(left, right, bottom, top, zNear, zFar) (all scalar value)
def inverse(...)
-
compute the inverse of a matrix or quaternion
Forms
matrix = igeVmath.inverse(matrix) quat = igeVmath.inverse(quat)
def length(...)
-
compute the length of a vector
Forms
float = igeVmath.length(vecN) (N = 2 or 3 or 4)
def lengthSqr(...)
-
compute the square of the length of a vector
Forms
float = igeVmath.lengthSqr(vecN) (N = 2 or 3 or 4)
def lerp(...)
-
linear interpolation between two vectors
Forms
vecN = igeVmath.lerp(t, vecN, vecN) (0<= t <= 1) (N = 2 or 3 or 4)
def lookAt(...)
-
construct viewing matrix based on eye position, position looked at, and up direction
Forms
matrix4 = igeVmath.lookAt(eyeVector, lookatVector, upVector)
def mat_identity(...)
-
construct an identity matrix
Forms
matrix = igeVmath.mat_identity(dimension) dimension : int dimention of output matrix (2,3,4)
def mat_rotation(...)
-
construct a matrix to rotate around a unit-length 3D vector
Forms
matrix = igeVmath.mat_rotation(radian, dimension, vector) dimension is 2 or 3 or 4 to output matrix if you omit vector, Zaxis(0,0,1) will be entered as default
def mat_rotationX(...)
-
construct a matrix to rotate around the Xaxis
Forms
matrix = igeVmath.mat_rotationX(radian, dimension) radian : float dimension : int dimension of output matrix (2,3,4)
def mat_rotationY(...)
-
construct a matrix to rotate around the Yaxis
Forms
matrix = igeVmath.mat_rotationY(radian, dimension) radian : float dimension : int dimension of output matrix (2,3,4)
def mat_rotationZ(...)
-
construct a matrix to rotate around the Zaxis
Forms
matrix = igeVmath.mat_rotationZ(radian, dimension) radian : float dimension : int dimension of output matrix (2,3,4)
def mat_rotationZYX(...)
-
construct a matrix to rotate around the x, y, and z axes
Forms
matrix = igeVmath.mat_rotationZYX(dimension, (xradian, yradian, zradian) ) dimension : int dimention of output matrix (2,3,4) xradian:float yradian:float zradian:float
def mat_scale(...)
-
construct a matrix to perform scaling
Forms
matrix = igeVmath.mat_scale(dimension, vector) dimension is 2 or 3 or 4 to output matrix
def mat_transform(...)
-
construct a 4x4 matrix from vector of position, rotation, scale and matrix of shear
Forms
matrix = igeVmath.mat_transform(position, rotation, scale, shear) position : igeVmath.vec3 (or (...), [...]) rotation : igeVmath.euler or igeVmath.quat (or (...), [...]) Rotateion can be specified in either Euler angles or quaternions. In the case of tuples and lists, if the number of elements is three it is interpreted as Euler angles, and if it is four it is interpreted as a quaternion. scale : igeVmath.vec3 (or (...), [...]) shear : igeVmath.mat44 (optional)
def mat_translation(...)
-
construct a 4x4 matrix to perform translation
Forms
matrix = igeVmath.mat_translation(vector)
def max(...)
-
maximum element of a vector
Forms
float = igeVmath.max(vecN) (N = 2 or 3 or 4)
def maxElem(...)
-
maximum of two vectors per element
Forms
vecN = igeVmath.maxElem(vecN,vecN) (N = 2 or 3 or 4)
def min(...)
-
minimum element of a vector
Forms
float = igeVmath.min(vecN) (N = 2 or 3 or 4)
def minElem(...)
-
minimum of two vectors per element
Forms
vecN = igeVmath.minElem(vecN,vecN) (N = 2 or 3 or 4)
def mul(...)
-
multiply 2 elements
Forms
vecN = igeVmath.mul(vecN, float) matNN = igeVmath.mul(matNN, float) vecN = igeVmath.mul(matNN, vecN) matNN = igeVmath.mul(matNN, matNN) quat = igeVmath.mul(quat, quat) vecN = igeVmath.mul(vecN, vecN) (multiply per element) (N = 2 or 3 or 4)
def normalize(...)
-
normalize a vector
Forms
vecN = igeVmath.normalize(vecN) (N = 2 or 3 or 4)
def orthoInverse(...)
-
compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix this can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions
Forms
matrix = igeVmath.orthoInverse(matrix)
def orthographic(...)
-
construct an orthographic projection matrix
Forms
matrix4 = igeVmath.orthographic(left, right, bottom, top, zNear, zFar) (all scalar value)
def perspective(...)
-
construct a perspective projection matrix
Forms
matrix4 = igeVmath.perspective(fovyRadians, aspect, zNear, zFar)
def prependScale(...)
-
prepend (pre-multiply) a scale transformation to a 4x4 matrix faster than creating and multiplying a scale transformation matrix
Forms
matrix = igeVmath.prependScale(matrix, vector)
def quat_look_rotation(...)
-
Creates a rotation with the specified forward and upwards directions. - Z axis will be aligned with forward - X axis aligned with cross product between forwardand upwards - Y axis aligned with cross product between Z and X
vmath.quat_look_rotation(forward: vmath.vec3, up: vmath.vec3)
Parameters
forward: forward vector up: up vector
def quat_rotation(...)
-
construct a quaternion
Forms
quat = igeVmath.quat_rotation(vec3, vec3) construct a quaternion to rotate between two unit - length 3D vectors the result is unpredictable if 2 vectors point in opposite directions quat = igeVmath.quat_rotation(float, vec3) construct a quaternion to rotate around a unit-length 3D vector quat = igeVmath.quat_rotation(float) construct a quaternion to rotate around a Z(0,0,1) axis
def quat_rotationX(...)
-
construct a quaternion to rotate around the x axis
Forms
quat = igeVmath.quat_rotationX(radian)
def quat_rotationY(...)
-
construct a quaternion to rotate around the y axis
Forms
quat = igeVmath.quat_rotationY(radian)
def quat_rotationZ(...)
-
construct a quaternion to rotate around the z axis
Forms
quat = igeVmath.quat_rotationZ(radian)
def quat_rotationZYX(...)
-
construct a quaternion to rotate around the x, y, and z axes
Forms
quat = igeVmath.quat_rotationZYX( (xradian, yradian, zradian) )
def recip(...)
-
compute the reciprocal of a vector per element
Forms
vecN = igeVmath.recip(vecN) (N = 2 or 3 or 4)
def rotate(...)
-
use a unit - length quaternion to rotate a 3D vector
Forms
vec = igeVmath.rotate(vec, quat)
def rsqrt(...)
-
compute the reciprocal square root of a vector per element
Forms
vecN = igeVmath.rsqrt(vecN) (N = 2 or 3 or 4)
def slerp(...)
-
spherical linear interpolation between two vectors
Forms
vecN = igeVmath.slerp(t, vecN, vecN) (0<= t <= 1) (N = 2 or 3 or 4)
def sqrt(...)
-
compute the square root of a vector per element
Forms
vecN = igeVmath.sqrt(vecN) (N = 2 or 3 or 4)
def squad(...)
-
spherical quadrangle interpolation
Forms
quat = igeVmath.squad(t,quat, quat, quat, quat)
def sub(...)
-
sub two vectors or two matrices
Forms
vecN = igeVmath.sub(vecN, vecM) matNN = igeVmath.sub(matNN, matMM) N,M = 2 or 3 or 4 type of return value is depend on first parameter type
def sum(...)
-
compute the sum of all elements of a vector
Forms
float = igeVmath.sum(vecN) (N = 2 or 3 or 4)
def transpose(...)
-
transpose of a matrix
Forms
matrix = igeVmath.transpose(matrix)
Classes
class aabb (...)
-
Axis aligned bounding box.
Instance variables
var area
-
Return an attribute of instance, which is of type owner.
var center
-
Return an attribute of instance, which is of type owner.
var extent
-
Return an attribute of instance, which is of type owner.
var lengthSqr
-
Return an attribute of instance, which is of type owner.
var maxEdge
-
Return an attribute of instance, which is of type owner.
var minEdge
-
Return an attribute of instance, which is of type owner.
var volume
-
Return an attribute of instance, which is of type owner.
Methods
def insert(...)
def isInside(...)
def repair(...)
def reset(...)
class euler (...)
-
a structure of auler angles
Constructors
igeVmath.euler() all values are set 0 igeVmath.euler(tilt, pan, roll) igeVmath.euler(euler) igeVmath.euler(quat)) convert from quaternion igeVmath.euler(mat3) convert from 3x3 rotation matrix
Parameters
tilt : float pan : float roll : float euler : igeVmath.euler quat : igeVmath.quat mat3 : igeVmath.mat3
Instance variables
var pan
-
Return an attribute of instance, which is of type owner.
var roll
-
Return an attribute of instance, which is of type owner.
var tilt
-
Return an attribute of instance, which is of type owner.
var x
-
Return an attribute of instance, which is of type owner.
var y
-
Return an attribute of instance, which is of type owner.
var z
-
Return an attribute of instance, which is of type owner.
Methods
def getElem(...)
-
Get a value using an index
Forms
value = obj.getElem(index) obj : vec2 vec3 vec4 euler index : int value : float
def setElem(...)
-
Set a value using an index
Forms
obj.setElem(index, value) obj : vec2 vec3 vec4 euler index : int value : float
def toQuat(...)
-
Compute the quaternion corresponding to Euler angles.
Forms
obj.toQuat()
class mat22 (...)
-
a 2x2 matrix in array-of-structures format
Constructors
igeVmath.mat22(flaot, ...) igeVmath.mat22((), ()) igeVmath.mat22([], []) igeVmath.mat22(vec2, vec2) Missing elements will be zero Extra elements are ignored Any other combination is possible
Instance variables
var m00
-
Return an attribute of instance, which is of type owner.
var m01
-
Return an attribute of instance, which is of type owner.
var m10
-
Return an attribute of instance, which is of type owner.
var m11
-
Return an attribute of instance, which is of type owner.
Methods
def getCol(...)
-
Returns the vector of column corresponding to the specified row.
Forms
vec = obj.getCol(row) vec : vec2,vec3,vec4 obj : mat2,mat3,mat4 row : int
def getElem(...)
-
Get a value using an index
Forms
value = obj.getElem(colmn, row) obj : mat2 mat3 mat4 colmn : int row : int value : float
def getRow(...)
-
Returns the vector of row corresponding to the specified column.
Forms
vec = obj.getRow(row) vec : vec2,vec3,vec4 obj : mat2,mat3,mat4 column : int
def setCol(...)
-
Set the column corresponding to the specified row.
Forms
obj.setCol(row, value) obj : mat2,mat3,mat4 row : int value : vec2,vec3,vec4
def setElem(...)
-
Set a value using an index
Forms
obj.setElem(colmn, row, value) obj : mat2 mat3 mat4 colmn : int row : int value : float
def setRow(...)
-
Set the row corresponding to the specified column.
Forms
obj.setCol(column, value) obj : mat2,mat3,mat4 column : int value : vec2,vec3,vec4
class mat33 (...)
-
a 3x3 matrix in array-of-structures format
Constructors
igeVmath.mat33(flaot, ...) igeVmath.mat33((), ...) igeVmath.mat33([], ...) igeVmath.mat33(vec3, ...) Missing elements will be zero Extra elements are ignored Any other combination is possible
Instance variables
var m00
-
Return an attribute of instance, which is of type owner.
var m01
-
Return an attribute of instance, which is of type owner.
var m02
-
Return an attribute of instance, which is of type owner.
var m10
-
Return an attribute of instance, which is of type owner.
var m11
-
Return an attribute of instance, which is of type owner.
var m12
-
Return an attribute of instance, which is of type owner.
var m20
-
Return an attribute of instance, which is of type owner.
var m21
-
Return an attribute of instance, which is of type owner.
var m22
-
Return an attribute of instance, which is of type owner.
Methods
def getCol(...)
-
Returns the vector of column corresponding to the specified row.
Forms
vec = obj.getCol(row) vec : vec2,vec3,vec4 obj : mat2,mat3,mat4 row : int
def getElem(...)
-
Get a value using an index
Forms
value = obj.getElem(colmn, row) obj : mat2 mat3 mat4 colmn : int row : int value : float
def getRow(...)
-
Returns the vector of row corresponding to the specified column.
Forms
vec = obj.getRow(row) vec : vec2,vec3,vec4 obj : mat2,mat3,mat4 column : int
def setCol(...)
-
Set the column corresponding to the specified row.
Forms
obj.setCol(row, value) obj : mat2,mat3,mat4 row : int value : vec2,vec3,vec4
def setElem(...)
-
Set a value using an index
Forms
obj.setElem(colmn, row, value) obj : mat2 mat3 mat4 colmn : int row : int value : float
def setRow(...)
-
Set the row corresponding to the specified column.
Forms
obj.setCol(column, value) obj : mat2,mat3,mat4 column : int value : vec2,vec3,vec4
class mat44 (...)
-
a 4x4 matrix in array-of-structures format
Constructors
igeVmath.mat44(flaot, ...) igeVmath.mat44((), ...) igeVmath.mat44([], ...) igeVmath.mat44(vec3, ...) igeVmath.mat44(vec4, ...) Missing elements will be zero but m[3][3] is 1.0 Extra elements are ignored Any other combination is possible
Instance variables
var m00
-
Return an attribute of instance, which is of type owner.
var m01
-
Return an attribute of instance, which is of type owner.
var m02
-
Return an attribute of instance, which is of type owner.
var m03
-
Return an attribute of instance, which is of type owner.
var m10
-
Return an attribute of instance, which is of type owner.
var m11
-
Return an attribute of instance, which is of type owner.
var m12
-
Return an attribute of instance, which is of type owner.
var m13
-
Return an attribute of instance, which is of type owner.
var m20
-
Return an attribute of instance, which is of type owner.
var m21
-
Return an attribute of instance, which is of type owner.
var m22
-
Return an attribute of instance, which is of type owner.
var m23
-
Return an attribute of instance, which is of type owner.
var m30
-
Return an attribute of instance, which is of type owner.
var m31
-
Return an attribute of instance, which is of type owner.
var m32
-
Return an attribute of instance, which is of type owner.
var m33
-
Return an attribute of instance, which is of type owner.
Methods
def getCol(...)
-
Returns the vector of column corresponding to the specified row.
Forms
vec = obj.getCol(row) vec : vec2,vec3,vec4 obj : mat2,mat3,mat4 row : int
def getElem(...)
-
Get a value using an index
Forms
value = obj.getElem(colmn, row) obj : mat2 mat3 mat4 colmn : int row : int value : float
def getRow(...)
-
Returns the vector of row corresponding to the specified column.
Forms
vec = obj.getRow(row) vec : vec2,vec3,vec4 obj : mat2,mat3,mat4 column : int
def getTransform(...)
-
construct a 4x4 matrix from vector of position, rotation, scale and matrix of shear
Forms
position, rotation, scale, shear = mat4.getTransform(rotationInEuler) rotationInEuler : bool Retriave the rotation in Euler angles. False, quaternion. position : igeVmath.vec3 rotation : igeVmath.vec3 scale : igeVmath.vec3 shear : igeVmath.mat44
def setCol(...)
-
Set the column corresponding to the specified row.
Forms
obj.setCol(row, value) obj : mat2,mat3,mat4 row : int value : vec2,vec3,vec4
def setElem(...)
-
Set a value using an index
Forms
obj.setElem(colmn, row, value) obj : mat2 mat3 mat4 colmn : int row : int value : float
def setRow(...)
-
Set the row corresponding to the specified column.
Forms
obj.setCol(column, value) obj : mat2,mat3,mat4 column : int value : vec2,vec3,vec4
class quat (...)
-
a quaternion in array-of-structures format
Constructors
igeVmath.quat(float, ...) igeVmath.quat(float,...)) igeVmath.quat([float,...]) igeVmath.quat(vec2) igeVmath.quat(vec3) igeVmath.quat(vec4) igeVmath.quat(quat) Missing elements will be zero Extra elements are ignored Any other combination is possible
Instance variables
var w
-
Return an attribute of instance, which is of type owner.
var x
-
Return an attribute of instance, which is of type owner.
var y
-
Return an attribute of instance, which is of type owner.
var z
-
Return an attribute of instance, which is of type owner.
Methods
def getElem(...)
-
Get a value using an index
Forms
value = obj.getElem(index) obj : vec2 vec3 vec4 euler index : int value : float
def normalize(...)
-
normalize a vector
Forms
vecN = igeVmath.normalize(vecN) (N = 2 or 3 or 4)
def setElem(...)
-
Set a value using an index
Forms
obj.setElem(index, value) obj : vec2 vec3 vec4 euler index : int value : float
class vec2 (...)
-
a 2-D vector in array-of-structures format
Constructors
igeVmath.vec2(float igeVmath.vec2(float,float) igeVmath.vec2((float,float)) igeVmath.vec2([float,float]) igeVmath.vec2(vec2) igeVmath.vec2(vec3) igeVmath.vec2(vec4) Missing elements will be zero Extra elements are ignored
Instance variables
var x
-
Return an attribute of instance, which is of type owner.
var y
-
Return an attribute of instance, which is of type owner.
Methods
def getElem(...)
-
Get a value using an index
Forms
value = obj.getElem(index) obj : vec2 vec3 vec4 euler index : int value : float
def normalize(...)
-
normalize a vector
Forms
vecN = igeVmath.normalize(vecN) (N = 2 or 3 or 4)
def setElem(...)
-
Set a value using an index
Forms
obj.setElem(index, value) obj : vec2 vec3 vec4 euler index : int value : float
class vec3 (...)
-
a 3-D vector in array-of-structures formatn
Constructors
igeVmath.vec3(float, ...) igeVmath.vec3(float,...)) igeVmath.vec3([float,...]) igeVmath.vec3(vec2) igeVmath.vec3(vec3) igeVmath.vec3(vec4) Missing elements will be zero Extra elements are ignored Any other combination is possible
Instance variables
var x
-
Return an attribute of instance, which is of type owner.
var y
-
Return an attribute of instance, which is of type owner.
var z
-
Return an attribute of instance, which is of type owner.
Methods
def getElem(...)
-
Get a value using an index
Forms
value = obj.getElem(index) obj : vec2 vec3 vec4 euler index : int value : float
def normalize(...)
-
normalize a vector
Forms
vecN = igeVmath.normalize(vecN) (N = 2 or 3 or 4)
def setElem(...)
-
Set a value using an index
Forms
obj.setElem(index, value) obj : vec2 vec3 vec4 euler index : int value : float
class vec4 (...)
-
a 4-D vector in array-of-structures format
Constructors
igeVmath.vec4(float, ...) igeVmath.vec4(float,...)) igeVmath.vec4([float,...]) igeVmath.vec4(vec2) igeVmath.vec4(vec3) igeVmath.vec4(vec4) igeVmath.vec4(quat) Missing elements will be zero Extra elements are ignored Any other combination is possible
Instance variables
var w
-
Return an attribute of instance, which is of type owner.
var x
-
Return an attribute of instance, which is of type owner.
var y
-
Return an attribute of instance, which is of type owner.
var z
-
Return an attribute of instance, which is of type owner.
Methods
def getElem(...)
-
Get a value using an index
Forms
value = obj.getElem(index) obj : vec2 vec3 vec4 euler index : int value : float
def normalize(...)
-
normalize a vector
Forms
vecN = igeVmath.normalize(vecN) (N = 2 or 3 or 4)
def setElem(...)
-
Set a value using an index
Forms
obj.setElem(index, value) obj : vec2 vec3 vec4 euler index : int value : float