![]() |
![]() |
![]() |
Pigment 0.3 Reference Manual | ![]() |
---|---|---|---|---|
#include <pgm/pgm.h> PgmVec3; PgmVec4; PgmMat4x4; #define PGM_VEC3_INIT (vec,v0,v1,v2) #define PGM_VEC3_COPY (dest,src) #define PGM_VEC4_INIT (vec,v0,v1,v2,v3) #define PGM_VEC4_COPY (dest,src) #define PGM_MAT4X4_ROW_INIT (mat,row,v0,v1,v2,v3) #define PGM_MAT4X4_INIT (mat,v00,v01,v02,v03,v10,v11,v12,v13,v20,v21,v22,v23,v30,v31,v32,v33) #define PGM_MAT4X4_IDENTITY (mat) #define PGM_MAT4X4_COPY (dest,src) gfloat pgm_vec3_length (const PgmVec3 *v); void pgm_vec3_normalize (PgmVec3 *v); void pgm_vec3_scale (PgmVec3 *v, const PgmVec3 *v1, const gfloat k); void pgm_vec3_sum (PgmVec3 *v, const PgmVec3 *v1, const PgmVec3 *v2); void pgm_vec3_cross_product (PgmVec3 *v, const PgmVec3 *v1, const PgmVec3 *v2); gfloat pgm_vec3_dot_product (const PgmVec3 *v1, const PgmVec3 *v2); void pgm_vec4_mult_mat4x4_vec4 (PgmVec4 *v, const PgmMat4x4 *m1, const PgmVec4 *v1); void pgm_mat4x4_transpose (PgmMat4x4 *m, const PgmMat4x4 *m1); gboolean pgm_mat4x4_inverse (PgmMat4x4 *m, const PgmMat4x4 *m1); void pgm_mat4x4_rotate_x (PgmMat4x4 *m, gfloat theta); void pgm_mat4x4_rotate_y (PgmMat4x4 *m, gfloat theta); void pgm_mat4x4_rotate_z (PgmMat4x4 *m, gfloat theta); void pgm_mat4x4_rotate (PgmMat4x4 *m, const PgmVec3 *axis, gfloat theta); void pgm_mat4x4_translate (PgmMat4x4 *m, const PgmVec3 *t); void pgm_mat4x4_scale (PgmMat4x4 *m, const PgmVec3 *s); void pgm_mat4x4_scale_along_axis (PgmMat4x4 *m, const PgmVec3 *axis, gfloat k); void pgm_mat4x4_mult_mat4x4_mat4x4 (PgmMat4x4 *m, const PgmMat4x4 *m1, const PgmMat4x4 *m2); gboolean pgm_intersection_line_plane (PgmVec3 *v, const PgmVec3 *l1, const PgmVec3 *l2, const PgmVec3 *p, const PgmVec3 *pu, const PgmVec3 *pv); gboolean pgm_vec3_belongs_rectangle (const PgmVec3 *p, const PgmVec3 *r, const PgmVec3 *ru, const PgmVec3 *rv);
typedef struct { gfloat v[3]; } PgmVec3;
Describes a 3 components vector.
gfloat v [3]; |
the 3 components vector array. |
typedef struct { gfloat v[4]; } PgmVec4;
Describes a 4 components vector.
gfloat v [4]; |
the 4 components vector array. |
typedef struct { gfloat m[4][4]; } PgmMat4x4;
Describes a 4x4 matrix in row major order.
gfloat m [4][4]; |
the 4x4 matrix array. |
#define PGM_VEC3_INIT(vec,v0,v1,v2)
Initializes vec
3 components vector.
vec : |
the 3 components vector. |
v0 : |
the 1st component. |
v1 : |
the 2nd component. |
v2 : |
the 3rd component. |
#define PGM_VEC3_COPY(dest,src)
Copies contents from src
3 component vector dest
3 components vector.
dest : |
the destination 3 components vector. |
src : |
the source 3 components vector. |
#define PGM_VEC4_INIT(vec,v0,v1,v2,v3)
Initializes vec
4 components vector.
vec : |
the 4 components vector. |
v0 : |
the 1st component. |
v1 : |
the 2nd component. |
v2 : |
the 3rd component. |
v3 : |
the 4th component. |
#define PGM_VEC4_COPY(dest,src)
Copies contents from src
4 component vector dest
4 components vector.
dest : |
the destination 4 components vector. |
src : |
the source 4 components vector. |
#define PGM_MAT4X4_ROW_INIT(mat,row,v0,v1,v2,v3)
Initializes the row row
of the mat
4x4 matrix.
mat : |
the 4x4 matrix. |
row : |
the row number. |
v0 : |
the 1st component of the row. |
v1 : |
the 2nd component of the row. |
v2 : |
the 3rd component of the row. |
v3 : |
the 4th component of the row. |
#define PGM_MAT4X4_INIT(mat,v00,v01,v02,v03,v10,v11,v12,v13,v20,v21,v22,v23,v30,v31,v32,v33)
Initializes mat
4x4 matrix.
mat : |
the 4x4 matrix. |
v00 : |
the 1st component of the 1st row. |
v01 : |
the 2nd component of the 1st row. |
v02 : |
the 3rd component of the 1st row. |
v03 : |
the 4th component of the 1st row. |
v10 : |
the 1st component of the 2nd row. |
v11 : |
the 2nd component of the 2nd row. |
v12 : |
the 3rd component of the 2nd row. |
v13 : |
the 4th component of the 2nd row. |
v20 : |
the 1st component of the 3rd row. |
v21 : |
the 2nd component of the 3rd row. |
v22 : |
the 3rd component of the 3rd row. |
v23 : |
the 4th component of the 3rd row. |
v30 : |
the 1st component of the 4th row. |
v31 : |
the 2nd component of the 4th row. |
v32 : |
the 3rd component of the 4th row. |
v33 : |
the 4th component of the 4th row. |
#define PGM_MAT4X4_IDENTITY(mat)
Initializes mat
4x4 matrix to the 4x4 identity matrix.
mat : |
the 4x4 matrix. |
#define PGM_MAT4X4_COPY(dest,src)
Copies contents from src
4x4 matrix to dest
4x4 matrix.
dest : |
the destination 4x4 matrix. |
src : |
the source 4x4 matrix. |
gfloat pgm_vec3_length (const PgmVec3 *v);
Retrieves the length of the 3 components vector v
.
MT safe.
v : |
the 3 components vector. |
Returns : | the length of v .
|
void pgm_vec3_normalize (PgmVec3 *v);
Performs an in place normalization of the v
3 components vector.
MT safe.
v : |
the 3 components vector. |
void pgm_vec3_scale (PgmVec3 *v, const PgmVec3 *v1, const gfloat k);
Computes the multiplication of the 3 components vector v1
by the
scalar k
in the 3 components vector v
.
MT safe.
v : |
the resulting 3 components vector. |
v1 : |
the 3 components vector to scale. |
k : |
the scalar to scale with. |
void pgm_vec3_sum (PgmVec3 *v, const PgmVec3 *v1, const PgmVec3 *v2);
Computes the multiplication of the 3 components vector v1
by the
scalar k
in the 3 components vector v
.
MT safe.
v : |
the resulting 3 components vector. |
v1 : |
a 3 components vector to add. |
v2 : |
a 3 components vector to add. |
void pgm_vec3_cross_product (PgmVec3 *v, const PgmVec3 *v1, const PgmVec3 *v2);
Computes the cross product of the 3 components vector v1
by the
the 3 components vector v2
in the 3 components vector v
.
MT safe.
v : |
the resulting 3 components vector. |
v1 : |
a 3 components vector to multiply. |
v2 : |
a 3 components vector to multiply. |
gfloat pgm_vec3_dot_product (const PgmVec3 *v1, const PgmVec3 *v2);
Computes the dot product of the 3 components vector v1
by the
the 3 components vector v2
.
MT safe.
v1 : |
a 3 components vector to multiply. |
v2 : |
a 3 components vector to multiply. |
Returns : | the dot product of v1 by v2 .
|
void pgm_vec4_mult_mat4x4_vec4 (PgmVec4 *v, const PgmMat4x4 *m1, const PgmVec4 *v1);
Computes the m
4x4 matrix product of the m1
4x4 matrix by the v1
4 components vector.
MT safe.
v : |
the resulting 4 components vector. |
m1 : |
the 4x4 matrix. |
v1 : |
the 4 components vector. |
void pgm_mat4x4_transpose (PgmMat4x4 *m, const PgmMat4x4 *m1);
Computes transpose matrix of the m1
4x4 matrix in the m
4x4 matrix.
MT safe.
m : |
the transpose 4x4 matrix. |
m1 : |
the 4x4 matrix. |
gboolean pgm_mat4x4_inverse (PgmMat4x4 *m, const PgmMat4x4 *m1);
Computes inverse matrix of the m1
4x4 matrix in the m
4x4 matrix.
MT safe.
m : |
the inverse 4x4 matrix. |
m1 : |
the 4x4 matrix. |
Returns : | TRUE for success, FALSE otherwise (singular matrix).
|
void pgm_mat4x4_rotate_x (PgmMat4x4 *m, gfloat theta);
Performs an in place rotation of the m
4x4 matrix about the x cardinal axis.
MT safe.
m : |
the 4x4 matrix. |
theta : |
the amount of rotation, in radians. |
void pgm_mat4x4_rotate_y (PgmMat4x4 *m, gfloat theta);
Performs an in place rotation of the m
4x4 matrix about the y cardinal axis.
MT safe.
m : |
the 4x4 matrix. |
theta : |
the amount of rotation, in radians. |
void pgm_mat4x4_rotate_z (PgmMat4x4 *m, gfloat theta);
Performs an in place rotation of the m
4x4 matrix about the z cardinal axis.
MT safe.
m : |
the 4x4 matrix. |
theta : |
the amount of rotation, in radians. |
void pgm_mat4x4_rotate (PgmMat4x4 *m, const PgmVec3 *axis, gfloat theta);
Performs an in place rotation of the m
4x4 matrix about an arbitrary axis.
MT safe.
m : |
the 4x4 matrix. |
axis : |
the axis of rotation, must be a unit vector. |
theta : |
the amount of rotation, in radians. |
void pgm_mat4x4_translate (PgmMat4x4 *m, const PgmVec3 *t);
Performs an in place translation of the m
4x4 matrix.
MT safe.
m : |
the 4x4 matrix. |
t : |
the translation to apply. |
void pgm_mat4x4_scale (PgmMat4x4 *m, const PgmVec3 *s);
Performs an in place scaling of the m
4x4 matrix.
MT safe.
m : |
the 4x4 matrix. |
s : |
the scale to apply. |
void pgm_mat4x4_scale_along_axis (PgmMat4x4 *m, const PgmVec3 *axis, gfloat k);
Performs an in place scaling of the m
4x4 matrix along an arbitrary axis.
MT safe.
m : |
the 4x4 matrix. |
axis : |
the axis of scale, must be a unit vector. |
k : |
the scale to apply. |
void pgm_mat4x4_mult_mat4x4_mat4x4 (PgmMat4x4 *m, const PgmMat4x4 *m1, const PgmMat4x4 *m2);
Computes the m
4x4 matrix product of the m1
4x4 matrix by the m2
4x4
matrix.
MT safe.
m : |
the resulting 4x4 matrix. |
m1 : |
the 1st 4x4 matrix. |
m2 : |
the 2nd 4x4 matrix. |
gboolean pgm_intersection_line_plane (PgmVec3 *v, const PgmVec3 *l1, const PgmVec3 *l2, const PgmVec3 *p, const PgmVec3 *pu, const PgmVec3 *pv);
Computes the intersection of the line defined going through the points l1
and l2
with the plane (p
, pu
, pv
), with p
a point of the plane, pu
and pv
two vectors colinear to the plane non colinear to each other.
The result is then put in v
if there is an intersection.
Warning: if the line (l1
, l2) belongs to the plane (p
, pu
, pv
) then
this function considers that there is no intersection instead.
MT safe.
v : |
the intersection point of the line and the plane if any. |
l1 : |
a point of the line. |
l2 : |
a point of the line. |
p : |
a point of the plane. |
pu : |
a vector colinear to the plane. |
pv : |
a vector colinear to the plane. |
Returns : | TRUE if the line (l1 , l2 ) intersects the plane (p , pu , pv ),
FALSE otherwise.
|
gboolean pgm_vec3_belongs_rectangle (const PgmVec3 *p, const PgmVec3 *r, const PgmVec3 *ru, const PgmVec3 *rv);
Decides if p
belongs to the rectangle defined by the point r
and the
vectors ru
and rv
.
MT safe.
p : |
the 3 components point. |
r : |
a 3 components vector defining the position top-left corner of the rectangle. |
ru : |
a 3 components vector defining the top edge of the rectangle. |
rv : |
a 3 components vector defining the left edge of the rectangle. |
Returns : | TRUE if the point p is inside the rectangle (r , ru , rv ), FALSE
otherwise.
|