Package Mathematics: cve.util.geom.mathematics3D
Import instruction :
import cve.math3D
About :
3D geometric mathematics functions This package provides list of functions to manipulate vectors and transformation matrices
It is extended with the trsf3D package which provides also plenty function, especially but not only about quaternion
Copyright (c) 2013 G-SCOP All rights reserved. Contributors Fr. Noel, T. Louis, P. Maigrot.
Functions
Function | summury |
---|---|
align_matrix(u0, u1) | Create a rotation matrix aligning two vectors (more…) |
boundedScalar(bound, scalar) | bound: Un réel positif représentant une valeur maximum en valeur absolue. (more…) |
combine_matrix(*x) | Multiply a list of matrices (more…) |
createRotationMatrixFromRotation9D(rotation9D) | rotation9D: Un 9-Tuple représentant une matrice de rotation (ligne après ligne). (more…) |
createTransformMatrixFromRotation9DAndTranslation3D(rotation9D, translation3D) | rotation9D: Un 9-Tuple représentant une matrice de rotation (ligne après ligne). (more…) |
createTransformMatrixFromRotationMatrixAndTranslation3D(rotationMatrix, translation3D) | rotationMatrix: Une matrice de rotation. (more…) |
cross(vectorA, vectorB) | |
crossProduct(vectorA, vectorB) | : Le produit vectoriel des 2 vecteurs donnés. (more…) |
degreeToRadian(alpha) | |
degree_to_radian(alpha) | Convert degrees to radian (more…) |
determinant2DVectors(a, b) | Retourne le déterminants de deux vecteurs en 2D. (more…) |
distance(vectorA, vectorB) | : La norme de (vectorB - vectorA). (more…) |
distance_point_line(X, X0, X1) | Compute the distance between a point and a line (more…) |
distance_point_triangle(X, X0, X1, X2) | Compute the distance between a point and a 3D plance defined by 3 points (more…) |
dot(vectorA, vectorB) | |
extractRotationMatrixFromTransformMatrix(transform) | : La matrice de rotation comprise dans la matrice de transformation donnée. (more…) |
extractTranslationFromTransformMatrix(transform) | : Le vecteur de translation compris dans la matrice de transformation donnée. (more…) |
extract_rotation_matrix(X) | Extract the rotation part of a matrix (more…) |
extract_scale(X) | Extract scale factors of a matrix (more…) |
extract_translation_matrix(X) | Extract the translation part of a matrix (more…) |
extract_translation_scale_rotation(X) | Extract the various components of a transformation (more…) |
factorAddVectors(factor1, vector1, factor2, vector2) | Retourne une somme pondérée de vecteurs. (more…) |
getNorme(vector) | : La norme du vecteur donné. (more…) |
identity_matrix() | Create an identity matrix. (more…) |
inverseVector(vector) | : -vector (more…) |
isDiff(matrix1, matrix2, precision=1e-06) | Compare two matrices (more…) |
isZero(vect) | : True si vect est le vecteur nul. (more…) |
mat_mat(matrix1, matrix2) | product of two matrices (more…) |
normalize(vector) | : Le vecteur vector normalisé. (more…) |
normalizevector(u, l=None) | : Le vecteur vector normalisé mais utilise la norme l si elle est déjà connue (more…) |
orientationDistance(vectorA, vectorB) | : La norme de (abs(vectorB) - abs(vectorA)). (more…) |
orthonormal_frame(t, n) | Creates the vectors of an orthnormal frame based on the plane (t,n) (more…) |
rotation_frame_matrix(u, v, w) | Returns the matrix to tranfer a point in the basis (u,v,w) (more…) |
rotation_matrix(alpha, vec=0) | Create a Rotation matrix of angle alpha around axis x if vec=0 y if vec=1 else around z (more…) |
scalarProduct(vectorA, vectorB) | : Le produit scalaire des 2 vecteurs donnés. (more…) |
scale_matrix(scale, sy=None, sz=None) | Create a scaling matrix (more…) |
scale_position_matrix(X, scale) | Modify a transformation matrix to scale positions (more…) |
tomatrix(m) | transforme la valeur d’un objet à deux entrée m en matrice (sous forme de tableau). (more…) |
transformMatrixDotPosition3D(transform, position) | transform: Une matrice de transformation 4*4. (more…) |
transformMatrixFromAngleAndAxis(angle, direction, origin) | Create a transformation matrix of a rotation around a line (more…) |
transform_to_viewpoint(T, D) | create data (eye,focal and up) of a camera from the camera position (more…) |
transform_to_viewpoint_frame(T, D) | create data (eye,focal and up) of a camera from the camera position (more…) |
translation_matrix(x, y, z) | Create a translation matrix (more…) |
transpose(m) | transforme la valeur d’un objet à deux entrée m en matrice (sous forme de tableau). (more…) |
viewpoint_to_transform(eye, focal, up) | Create a transformation to define the position of a camera (more…) |
vtransformValueToMatrix(vtransformvalue) | Transform a double index 4x4 matrix in a double entry tuple. (more…) |
xyzAngleFromMatrix1ToMatrix2(rotation1, rotation2) | COmpute the rotation angle between two transformations (more…) |
Functions details
align_matrix
def align_matrix(u0, u1)
Create a rotation matrix aligning two vectors
the vectorial product of u0 and u1 defines the rotation axis the norm oif this vectorial product provides the sinus of the rotation angle
- →: u0 : first vector
- →: u1 : second vector
- ← the expected rotation matrix
boundedScalar
def boundedScalar(bound, scalar)
- → bound: Un réel positif représentant une valeur maximum en valeur absolue.
- → scalar: Un réel à borner en valeur absolue.
- ← Le réel borné.
combine_matrix
def combine_matrix(*x)
Multiply a list of matrices
- →: unbounded parameters matrices
- ← the product of all the matrices
createRotationMatrixFromRotation9D
def createRotationMatrixFromRotation9D(rotation9D)
- → rotation9D: Un 9-Tuple représentant une matrice de rotation (ligne après ligne).
- ← La matrice de rotation correspondant.
createTransformMatrixFromRotation9DAndTranslation3D
def createTransformMatrixFromRotation9DAndTranslation3D(rotation9D, translation3D)
- → rotation9D: Un 9-Tuple représentant une matrice de rotation (ligne après ligne).
- → translation3D: Un vecteur 3D de translation.
- ← La matrice de transformation 4*4 correspondant à la rotation et à la translation donnée.
createTransformMatrixFromRotationMatrixAndTranslation3D
def createTransformMatrixFromRotationMatrixAndTranslation3D(rotationMatrix, translation3D)
- → rotationMatrix: Une matrice de rotation.
- → translation3D: Un vecteur 3D de translation.
- ← La matrice de transformation 4*4 correspondant à la rotation et à la translation donnée.
crossProduct
def crossProduct(vectorA, vectorB)
- ← Le produit vectoriel des 2 vecteurs donnés.
degree_to_radian
def degree_to_radian(alpha)
Convert degrees to radian
- →: angle in degree
- ← value in radians
determinant2DVectors
def determinant2DVectors(a, b)
Retourne le déterminants de deux vecteurs en 2D.
- → a et b sont des vecteurs de dimension 2.
- ← a[0]b[1]-a[1]b[0]
distance
def distance(vectorA, vectorB)
- ← La norme de (vectorB - vectorA).
distance_point_line
def distance_point_line(X, X0, X1)
Compute the distance between a point and a line
- → X: the point
- → X0: first point defining the line
- → X1: second point defining the line
- ← The distance between a point and the line defined by two points
points are given by a tuple of 3 coordinates
distance_point_triangle
def distance_point_triangle(X, X0, X1, X2)
Compute the distance between a point and a 3D plance defined by 3 points
- → X: the point
- → X0: first point defining the plane
- → X1: second point defining the plane
- → X2: third point defining the plane
- ← The distance between a point and the plane defined by three points
points are given by a tuple of 3 coordinates
extractRotationMatrixFromTransformMatrix
def extractRotationMatrixFromTransformMatrix(transform)
- ← La matrice de rotation comprise dans la matrice de transformation donnée.
extractTranslationFromTransformMatrix
def extractTranslationFromTransformMatrix(transform)
- ← Le vecteur de translation compris dans la matrice de transformation donnée.
extract_rotation_matrix
def extract_rotation_matrix(X)
Extract the rotation part of a matrix
- →: X : the input matrix
- ← the rotation and scaling part of the matrix (translation removed)
extract_scale
def extract_scale(X)
Extract scale factors of a matrix
- →: X : the input matrix
- ← a tuple of 3 floats matching the scaling effect along x, y and z.
extract_translation_matrix
def extract_translation_matrix(X)
Extract the translation part of a matrix
- →: X : the input matrix
- ← the translation part of the matrix
extract_translation_scale_rotation
def extract_translation_scale_rotation(X)
Extract the various components of a transformation
- →: X : the input matrix
- ← T,(sx,sy,sz),R :
- T is the translation part
- sx,sy,sz : a tuple of 3 floats matching the scaling effect along x, y and z.
- R is the rotation part
Thus X = [T] [S] [R]
factorAddVectors
def factorAddVectors(factor1, vector1, factor2, vector2)
Retourne une somme pondérée de vecteurs. Factor1 et factor2 sont des réels. Vector1 et vector2 sont des vecteurs de même dimension.
- ← factor1 * vector1 + factor2 * vector2
getNorme
def getNorme(vector)
- ← La norme du vecteur donné.
identity_matrix
def identity_matrix()
Create an identity matrix.
- ← a 4D identity matrix.
inverseVector
def inverseVector(vector)
- ← -vector
isDiff
def isDiff(matrix1, matrix2, precision=1e-06)
Compare two matrices
- → precision: L’erreure tolérée pour condidérer 2 matrices comme identiques. Valeur par défaut = 1.0e-6.
- ← False si les 2 matrices sont identiques à la précision demandée (la différence 2 à 2 de chaqun de leurs paramêtres est inférieure à precision).
isZero
def isZero(vect)
- ← True si vect est le vecteur nul.
mat_mat
def mat_mat(matrix1, matrix2)
product of two matrices
The size of matrices must be compatible unless False will be returned
- →: matrix1
- →: matrix2
- ← matrix product of the two given matrices
normalize
def normalize(vector)
- ← Le vecteur vector normalisé.
normalizevector
def normalizevector(u, l=None)
- ← Le vecteur vector normalisé mais utilise la norme l si elle est déjà connue
orientationDistance
def orientationDistance(vectorA, vectorB)
- ← La norme de (abs(vectorB) - abs(vectorA)).
orthonormal_frame
def orthonormal_frame(t, n)
Creates the vectors of an orthnormal frame based on the plane (t,n)
- → t a vector of the plane
- → n the z vector in the plane
- ← u,v,w where u and w are in the plane w = n v is the normal to the plane (t,n)
rotation_frame_matrix
def rotation_frame_matrix(u, v, w)
Returns the matrix to tranfer a point in the basis (u,v,w)
- → u first frame vector
- → v second frame vector
- → w third frame vector
- ← the expected matrix
rotation_matrix
def rotation_matrix(alpha, vec=0)
Create a Rotation matrix of angle alpha around axis x if vec=0 y if vec=1 else around z
- →: alpha rotation angle in radian
- →: vec : axis identification 0 : x axis,, 1 y axis, else z axis
- ← the expected rotation matrix
scalarProduct
def scalarProduct(vectorA, vectorB)
- ← Le produit scalaire des 2 vecteurs donnés.
scale_matrix
def scale_matrix(scale, sy=None, sz=None)
Create a scaling matrix
- →: scale : scale along x axis
- →: sy : default None : scale along y axis if specific? if not scale is used
- →: sy : default None : scale along y axis if specific? if not scale is used
- ← a scaling matrix
scale_position_matrix
def scale_position_matrix(X, scale)
Modify a transformation matrix to scale positions
- →: X : the transformed matrix
- →: scale : scale factor
- ← the scaled matrix
tomatrix
def tomatrix(m)
transforme la valeur d’un objet à deux entrée m en matrice (sous forme de tableau).
- → m:
transformMatrixDotPosition3D
def transformMatrixDotPosition3D(transform, position)
- → transform: Une matrice de transformation 4*4.
- → position: Une position 3D dans le repère de la transformation.
- ← La position demandée dans le repère universel (correspond à transform*position).
transformMatrixFromAngleAndAxis
def transformMatrixFromAngleAndAxis(angle, direction, origin)
Create a transformation matrix of a rotation around a line
- → angle: L’angle d’une rotation.
- → direction: La direction de l’axe d’une rotation.
- → origin: Le centre d’une rotation.
- ← La matrice de transformation 4*4 correspondant à la rotation demandée.
transform_to_viewpoint
def transform_to_viewpoint(T, D)
create data (eye,focal and up) of a camera from the camera position and the focal distance
- → T: The transformation matrix of the camera
- → D: The focal distance
-
← the position of eye, the focal point and the up vector
- The gaze is along y
- The rigth side is along x
- The up direction is along z
transform_to_viewpoint_frame
def transform_to_viewpoint_frame(T, D)
create data (eye,focal and up) of a camera from the camera position and the focal distance
- → T: The transformation matrix of the camera
- → D: The focal distance
- ← the position of eye, the focal point and the up vector
The gaze is along y The rigth side is along x The up direction is along z
translation_matrix
def translation_matrix(x, y, z)
Create a translation matrix
- →: x : translation along x
- →: y : translation along y
- →: z : translation along z
- ← a translation matrix
transpose
def transpose(m)
transforme la valeur d’un objet à deux entrée m en matrice (sous forme de tableau).
- →: m: the inout matrix
- ← the transposed matrix
viewpoint_to_transform
def viewpoint_to_transform(eye, focal, up)
Create a transformation to define the position of a camera
- →: The gaze is along y
- →: The rigth side is along x
- →: The up direction is along z
- ← the transformation and the distance from eye to focal point
vtransformValueToMatrix
def vtransformValueToMatrix(vtransformvalue)
Transform a double index 4x4 matrix in a double entry tuple.
- → vtransf: type vtransform
xyzAngleFromMatrix1ToMatrix2
def xyzAngleFromMatrix1ToMatrix2(rotation1, rotation2)
COmpute the rotation angle between two transformations
- ← The expected angles in xyz.