toolMatrix

toolMatrix — Defines basic handlings on matrix.

Functions

Types and Values

Description

Some very basic linear algebra are redefined here. It also gives access to coordinates conversion, essentially between cartesian and spherical.

Functions

tool_matrix_setIdentity ()

void
tool_matrix_setIdentity (float mat[3][3]);

Initialise mat with the identity.

Parameters

mat

a matrix location.

[array fixed-size=9]

Since: 3.7


tool_matrix_set ()

void
tool_matrix_set (float mat[3][3],
                 float orig[3][3]);

Copy orig into mat .

Parameters

mat

a matrix.

 

orig

a matrix.

 

Since: 3.8


tool_matrix_dtof ()

void
tool_matrix_dtof (float mf[3][3],
                  double md[3][3]);

Cast md into mf .

Parameters

mf

a matrix in single precision.

 

md

a matrix in double precision.

 

Since: 3.7


tool_matrix_productMatrix ()

void
tool_matrix_productMatrix (float matRes[3][3],
                           float matA[3][3],
                           float matB[3][3]);

Compute the mathematical product between matA and matB and put the result matrix in matRes .

Parameters

matRes

an array of floating point values of size 3x3 ;

 

matA

an array of floating point values of size 3x3 ;

 

matB

an array of floating point values of size 3x3.

 

Since: 3.2


tool_matrix_productVector ()

void
tool_matrix_productVector (float vectRes[3],
                           float mat[3][3],
                           float vect[3]);

Compute the mathematical product between matA and vect and put the result vector in vectRes .

Parameters

vectRes

an array of floating point values of size 3 ;

 

mat

an array of floating point values of size 3x3 ;

 

vect

an array of floating point values of size 3.

 

Since: 3.2


tool_matrix_invert ()

gboolean
tool_matrix_invert (float inv[3][3],
                    float mat[3][3]);

Calculate the inverse matrix of matrix mat and store it in inv .

Parameters

inv

a matrix (out values).

 

mat

a matrix.

 

Returns

FALSE if mat is singular.

Since: 3.6


tool_matrix_determinant ()

float
tool_matrix_determinant (float mat[3][3]);

Calculate the determinant of matrix mat .

Parameters

mat

a matrix.

 

Returns

the determinant value.

Since: 3.6


tool_matrix_rotate ()

void
tool_matrix_rotate (float mat[3][3],
                    float angle,
                    ToolXyzDir dir);

Create a rotation matrix along axis dir of the given angle .

Parameters

mat

a matrix.

 

angle

an angle in degrees.

 

dir

a direction.

 

Since: 3.8


tool_matrix_reducePrimitiveVectors ()

gboolean
tool_matrix_reducePrimitiveVectors (double reduced[6],
                                    double full[3][3]);

This routine transforms the given matrix full into a reduced array used by V_Sim to store box definition.

Parameters

reduced

a storage for 6 floating point values ;.

[out caller-allocates][array fixed-size=6]

full

a full 3x3 matrix to be transformed.

[in][array fixed-size=9]

Returns

FALSE if the given matrix is planar.


tool_matrix_getRotationFromFull ()

gboolean
tool_matrix_getRotationFromFull (float rot[3][3],
                                 double full[3][3],
                                 double box[6]);

There is a rotation matrix to transform from full cartesian coordinates into reduced box cartesian coordinates.

Parameters

rot

a rotation matrix (out values).

 

full

the description of basis set in full development.

 

box

the description of basis set in align X axis.

 

Returns

TRUE if full does not describe properly a 3D box.

Since: 3.6


tool_matrix_cartesianToSpherical ()

void
tool_matrix_cartesianToSpherical (float spherical[3],
                                  const float cartesian[3]);

A method to transform cartesian coordinates in spherical coordinates (radius, phi and theta).

Parameters

spherical

an allocated array of 3 floating point values to store the result ;

 

cartesian

an allocated array of 3 floating point values to read the input.

 

Since: 3.3


tool_matrix_sphericalToCartesian ()

void
tool_matrix_sphericalToCartesian (float cartesian[3],
                                  const float spherical[3]);

A method to transform spherical coordinates (radius, phi and theta) to cartesian coordinates.

Parameters

cartesian

an allocated array of 3 floating point values to store the result ;

 

spherical

an allocated array of 3 floating point values to read the input.

 

Since: 3.3


tool_vector_spherical ()

float
tool_vector_spherical (const float cart[3],
                       ToolMatrixSphericalCoord at);

Convert cart in spherical coordinates. It is equivalent to tool_matrix_cartesianToSpherical() but returns the value in a given direction only. This is intended for bindings.

Parameters

cart

a vector in cartesian coordinates.

[array fixed-size=3]

at

a spherical direction.

 

Returns

the coodinate in spherical.

Since: 3.8


tool_matrix_getScaledValue ()

float
(*tool_matrix_getScaledValue) (float x,
                               float minmax[2]);

Transform x into [0;1] using the given minmax values.

Parameters

x

the initial value ;

 

minmax

the boundaries for the x argument.

 

Returns

a value into [0;1].

Since: 3.4


tool_matrix_getScaledLinear ()

float
tool_matrix_getScaledLinear (float x,
                             float minmax[2]);

Transform x into [0;1] with a linear scale.

Parameters

x

the initial value ;

 

minmax

the boundaries for the x argument ;

 

Returns

a value into [0;1].

Since: 3.5


tool_matrix_getScaledLog ()

float
tool_matrix_getScaledLog (float x,
                          float minmax[2]);

Transform x into [0;1] with a log scale.

Parameters

x

the initial value ;

 

minmax

the boundaries for the x argument.

 

Returns

a value into [0;1].

Since: 3.5


tool_matrix_getScaledZeroCentredLog ()

float
tool_matrix_getScaledZeroCentredLog (float x,
                                     float minmax[2]);

Transform x into [0;1] with a log scale with zero centred values.

Parameters

x

the initial value ;

 

minmax

the boundaries for the x argument.

 

Returns

a value into [0;1].

Since: 3.5


tool_matrix_getScaledLinearInv ()

float
tool_matrix_getScaledLinearInv (float x,
                                float minmax[2]);

Reverse function for tool_matrix_getScaledLinear().

Parameters

x

the initial value ;

 

minmax

the boundaries for the x argument.

 

Returns

a value into [0;1].

Since: 3.5


tool_matrix_getScaledLogInv ()

float
tool_matrix_getScaledLogInv (float x,
                             float minmax[2]);

Reverse function for tool_matrix_getScaledLog().

Parameters

x

the initial value ;

 

minmax

the boundaries for the x argument.

 

Returns

a value into [0;1].

Since: 3.5


tool_matrix_getScaledZeroCentredLogInv ()

float
tool_matrix_getScaledZeroCentredLogInv
                               (float x,
                                float minmax[2]);

Reverse function for tool_matrix_getScaledZeroCentredLog().

Parameters

x

the initial value ;

 

minmax

the boundaries for the x argument.

 

Returns

a value into [0;1].

Since: 3.5


tool_matrix_getInter2D ()

gboolean
tool_matrix_getInter2D (float *lambda,
                        float a[2],
                        float b[2],
                        float A[2],
                        float B[2]);

Get the intersection coeeficient of lines [ab] and [AB].

Parameters

lambda

a location to store a float.

 

a

a point.

 

b

another point.

 

A

a point.

 

B

another point.

 

Returns

TRUE if [ab] and [AB] have an intersection.


tool_matrix_getInter2DFromList ()

gboolean
tool_matrix_getInter2DFromList (float i[2],
                                float *lambda,
                                float a[2],
                                float b[2],
                                GList *set);

Same as tool_matrix_getInter2D(), but from a list of points.

[skip]

Parameters

i

a location to store a point.

 

lambda

a location to store a float.

 

a

a point.

 

b

another point.

 

set

a list of points.

 

Returns

TRUE if an intersection exists.


tool_vector_set ()

gboolean
tool_vector_set (float dest[3],
                 const float orig[3]);

Copy orig into dest and also test if dest was already equals to orig .

Parameters

dest

a vector.

 

orig

a vector.

 

Returns

TRUE if dest is different from orig .

Since: 3.8


tool_vector_new ()

float *
tool_vector_new (const float orig[3]);

Creates a new ToolVector by copying orig .

Parameters

orig

a vector.

[array fixed-size=3]

Returns

.

[transfer full][type ToolVector]

Since: 3.8


tool_matrix_init ()

void
tool_matrix_init (void);

This method is used by V_Sim internally and should not be called.

[skip]

Since: 3.5


tool_minmax ()

void
tool_minmax (float global[2],
             const float minmax[2]);

Take the minimum and maximum of global and minmax and put them into global . global should be initialised.

Parameters

global

the global min and max values.

[array fixed-size=2]

minmax

some min and max values.

[array fixed-size=2]

Since: 3.8


tool_minmax_fromDbl ()

void
tool_minmax_fromDbl (float global[2],
                     const double minmax[2]);

Same as tool_minmax() for double inputs.

Parameters

global

the global min and max values.

[array fixed-size=2]

minmax

some min and max values.

[array fixed-size=2]

Since: 3.8

Types and Values

TOOL_XYZ_MASK_X

#define TOOL_XYZ_MASK_X (1 << 0)

This value can be used to create a mask for methods that require one for reading xyz coordinates array. This value actually correspond to the x direction.

Since: 3.3


TOOL_XYZ_MASK_Y

#define TOOL_XYZ_MASK_Y (1 << 1)

This value can be used to create a mask for methods that require one for reading xyz coordinates array. This value actually correspond to the y direction.

Since: 3.3


TOOL_XYZ_MASK_Z

#define TOOL_XYZ_MASK_Z (1 << 2)

This value can be used to create a mask for methods that require one for reading xyz coordinates array. This value actually correspond to the z direction.

Since: 3.3


TOOL_XYZ_MASK_ALL

#define TOOL_XYZ_MASK_ALL (7)

This value can be used to create a mask for methods that require one for reading xyz coordinates array. This value is a shortcut for TOOL_XYZ_MASK_X | TOOL_XYZ_MASK_Y | TOOL_XYZ_MASK_Z.

Since: 3.3


enum ToolXyzDir

The three space axis.

Members

TOOL_XYZ_X

the x axis;

 

TOOL_XYZ_Y

the y axis;

 

TOOL_XYZ_Z

the z axis.

 

Since: 3.8


TOOL_PI180

#define TOOL_PI180 0.017453292522

Value of pi / 180.


enum ToolMatrixSphericalCoord

This is used to access the ordering of the vectors with tool_matrix_cartesianToSpherical() or with tool_matrix_sphericalToCartesian().

Members

TOOL_MATRIX_SPHERICAL_MODULUS

the modulus of a spherical vector.

 

TOOL_MATRIX_SPHERICAL_THETA

the theta angle of a spherical vector.

 

TOOL_MATRIX_SPHERICAL_PHI

the phi angle of a spherical vector.

 

Since: 3.6


enum ToolMatrixScalingFlag

Flag used to specify the transformation for maps, see scalarFieldDraw_map() routine.

Members

TOOL_MATRIX_SCALING_LINEAR

a linear convertion from [min,max] to [0,1] ;

 

TOOL_MATRIX_SCALING_LOG

a TOOL_MATRIX_SCALING_LOGic transformation from [min,max] to [0,1], the formula is -(f(x) - f(m) / f(m) where f(x) = ln((x-xmin)/(xmax-xmin)) ;

 

TOOL_MATRIX_SCALING_ZERO_CENTRED_LOG

a TOOL_MATRIX_SCALING_LOGic transformation for data that are zero centred, the formula is 0.5+s*(log(MAX*SEUIL)-log(max(abs(x),MAX*SEUIL)))/(2*log(SEUIL)) where s is the sign, max=max(xmax,-xmin) and seuil a parameter (1e-5).

 

TOOL_MATRIX_SCALING_N_VALUES

number of available scale functions.

 

Since: 3.4


struct ToolGridSize

struct ToolGridSize {
  guint grid[3];
};

Structure used for bindings.

Members

guint grid[3];

.

[array fixed-size=3][element-type guint]

Since: 3.7