428 lines
21 KiB
C
428 lines
21 KiB
C
/* ##H_FILE#
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
FILE : Msw_3D.h
|
|
MODULE : sw (Common Mathematic Library)
|
|
|
|
DESCRIPTION : 3D Matrix implementation
|
|
|
|
VERSION : sw V5.0.13 / Alexandre LANGER [ALX] Ubi R&D / Add Comments
|
|
|
|
VERSION PC
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
*/
|
|
|
|
#ifndef __MATRICES_SW_3D__
|
|
#define __MATRICES_SW_3D__
|
|
|
|
/* ##TYPEDEF#----------------------------------------------------------------------------
|
|
Types definition
|
|
---------------------------------------------------------------------------------------*/
|
|
|
|
/* -----------------27/04/98 16:23-------------------
|
|
* Conversion : OK avec version 23.04.98 19:26 (44640)
|
|
* --------------------------------------------------*/
|
|
|
|
#define sw_3D_tdstMatrix MTH3D_tdstMatrix
|
|
|
|
/* ##MACRO#----------------------------------------------------------------------------
|
|
MACRO definition
|
|
---------------------------------------------------------------------------------------*/
|
|
|
|
/*+ ##-######################################
|
|
## MACRO AND FUNCTION FOR 3D MATHEMATICS
|
|
######################################### */
|
|
|
|
|
|
/* ##-###########################
|
|
## Matrix operations
|
|
############################## */
|
|
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vCopyMatrix
|
|
DESCRIPTION : Copy MatA in MatDest
|
|
INPUT : MatDest, MatA: address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vCopyMatrix( MatDest, MatA) MTH3D_M_vCopyMatrix( MatDest, MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vAddMatrix
|
|
DESCRIPTION : Add two matrix : MatDest= MatA + MatB
|
|
INPUT : MatDest, MatA, MatB: address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vAddMatrix( MatDest, MatA, MatB) MTH3D_M_vAddMatrix( MatDest, MatA, MatB)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vSubMatrix
|
|
DESCRIPTION : Sub two matrix : MatDest= MatA - MatB
|
|
INPUT : MatDest, MatA, MatB: address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vSubMatrix( MatDest, MatA, MatB) MTH3D_M_vSubMatrix( MatDest, MatA, MatB)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vNegMatrix
|
|
DESCRIPTION : Make the Nagation of a matrix : MatDest= -MatA
|
|
INPUT : MatDest, MatA: address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vNegMatrix( MatDest, MatA) MTH3D_M_vNegMatrix( MatDest, MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vMulMatrixMatrixWithoutBuffer
|
|
DESCRIPTION : Multiply two matrix : MatDest= MatA*MatB, MatDest must be a other matrix
|
|
INPUT : MatDest, MatA, MatB: address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vMulMatrixMatrixWithoutBuffer(MatDest, MatA, MatB) \
|
|
MTH3D_M_vMulMatrixMatrixWithoutBuffer(MatDest, MatA, MatB)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vMulMatrixMatrix
|
|
DESCRIPTION : Multiply two matrix : MatDest= MatA*MatB
|
|
INPUT : MatDest, MatA, MatB: address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vMulMatrixMatrix(Mat_Dest, Mat_A, Mat_B) \
|
|
MTH3D_M_vMulMatrixMatrix(Mat_Dest, Mat_A, Mat_B)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vMulTranspMatrixMatrixWithoutBuffer
|
|
DESCRIPTION : Multiply the transposed matrix to a other: MatDest= (transp MatA)*MatB,
|
|
MatDest must be a other matrix
|
|
INPUT : MatDest, MatA, MatB: address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vMulTranspMatrixMatrixWithoutBuffer(MatDest, MatA, MatB) \
|
|
MTH3D_M_vMulTranspMatrixMatrixWithoutBuffer(MatDest, MatA, MatB)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vMulTranspMatrixMatrix
|
|
DESCRIPTION : Multiply the transposed matrix to a other: MatDest= (transp MatA)*MatB,
|
|
INPUT : MatDest, MatA, MatB: address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vMulTranspMatrixMatrix(Mat_Dest, Mat_A, Mat_B) \
|
|
MTH3D_M_vMulTranspMatrixMatrix(Mat_Dest, Mat_A, Mat_B)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vMulScalarMatrix
|
|
DESCRIPTION : Multiply a scalar with a matrix : MatDest= a*MatA
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
a: SCA_td_sw, MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
/*
|
|
#define sw_3D_M_vMulScalarMatrix(MatDest, a, MatA) \
|
|
MTH3D_M_vMulScalarMatrix(MatDest, a, MatA)
|
|
*/
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vDivScalarMatrix
|
|
DESCRIPTION : Divide a matrix by a scalar : MatDest= MatA/a
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
MatA : address of sw_3D_tdstMatrix, a: SCA_td_sw
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
/*
|
|
#define sw_3D_M_vDivScalarMatrix(MatDest, MatA, a) \
|
|
MTH3D_M_vDivScalarMatrix(MatDest, MatA, a)
|
|
*/
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vSqrMatrix
|
|
DESCRIPTION : Square a matrix : MatDest= MatA*MatA
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vSqrMatrix(MatDest, MatA) MTH3D_M_vSqrMatrix(MatDest, MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vTranspMatrixWithoutBuffer
|
|
DESCRIPTION : Transpose a matrix : MatDest= transp MatA, Matdest must be a other matrix
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vTranspMatrixWithoutBuffer(MatDest, MatA) \
|
|
MTH3D_M_vTranspMatrixWithoutBuffer(MatDest, MatA)
|
|
|
|
|
|
/* sw_3D_M_vTranpMatrixWithoutBuffer(MatDest, MatA) : MatDest= transp MatA */
|
|
#define sw_3D_M_vTranpMatrixWithoutBuffer sw_3D_M_vTranspMatrixWithoutBuffer
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vTranspMatrix
|
|
DESCRIPTION : Transpose a matrix : MatDest= transp MatA
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vTranspMatrix(Mat_Dest, Mat_A) MTH3D_M_vTranspMatrix(Mat_Dest, Mat_A)
|
|
|
|
/* sw_3D_M_vTranpMatrix(MatDest, MatA) : MatDest= transp MatA */
|
|
#define sw_3D_M_vTranpMatrix sw_3D_M_vTranspMatrix
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_xTraceMatrix
|
|
DESCRIPTION : Return the trace of a matrix
|
|
INPUT : MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : trace MatA : SCA_td_sw
|
|
=======================================================================================*/
|
|
#define sw_3D_M_xTraceMatrix(MatA) MTH3D_M_xTraceMatrix(MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vSetIdentityMatrix
|
|
DESCRIPTION : Set a matrix to the Identity matrix : MatDest= Id
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vSetIdentityMatrix(MatDest) MTH3D_M_vSetIdentityMatrix(MatDest)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_bEqualMatrix
|
|
DESCRIPTION : Test if two matrix are equal
|
|
INPUT : MatA, MatB : address of sw_3D_tdstMatrix
|
|
OUTPUT : MatA==MatB : Boolean
|
|
=======================================================================================*/
|
|
#define sw_3D_M_bEqualMatrix(MatA, MatB) MTH3D_M_bEqualMatrix(MatA, MatB)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_bMatchMatrix
|
|
DESCRIPTION : Test if two matrix are neary equal
|
|
INPUT : MatA, MatB : address of sw_3D_tdstMatrix
|
|
eps : SCA_td_sw
|
|
OUTPUT : (MatA match MatB to within about eps) : Boolean
|
|
=======================================================================================*/
|
|
/*
|
|
#define sw_3D_M_bMatchMatrix(MatA, MatB, eps) MTH3D_M_bMatchMatrix(MatA, MatB, eps)
|
|
*/
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vFillMatrix
|
|
DESCRIPTION : Fill each matrix element with "a" value
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
a : SCA_td_sw
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vFillMatrix(MatDest, a) MTH3D_M_vFillMatrix(MatDest, a)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_xDetMatrix
|
|
DESCRIPTION : Return the determinant of a matrix
|
|
INPUT : MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : det MatA : SCA_td_sw
|
|
=======================================================================================*/
|
|
#define sw_3D_M_xDetMatrix(MatA) MTH3D_M_xDetMatrix(MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vComMatrixWithoutBuffer
|
|
DESCRIPTION : Calculate the Cofactor Matrix of a matrix : MatDest= Cofactor Matrix of MatA
|
|
INPUT : Matdest, MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vComMatrixWithoutBuffer(MatDest, MatA) \
|
|
MTH3D_M_vComMatrixWithoutBuffer(MatDest, MatA) \
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vInverMatrix
|
|
DESCRIPTION : Invert a matrix : MatDest= Inv MatA
|
|
INPUT : Matdest, MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vInverMatrix(MatDest, MatA) MTH3D_M_vInverMatrix(MatDest, MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vGetMatrixColumnElements
|
|
DESCRIPTION : Get x, y, z column col values in MatA
|
|
INPUT : x, y, z : SCA_td_sw
|
|
col : int
|
|
MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vGetMatrixColumnElements( Vx, Vy, Vz, col, MatA) \
|
|
MTH3D_M_vGetMatrixColumnElements( Vx, Vy, Vz, col, MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vSetMatrixColumnElements
|
|
DESCRIPTION : Set column col x, y, z values in MatDest
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
x, y, z : SCA_td_sw
|
|
col : int
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vSetMatrixColumnElements( MatDest, Vx, Vy, Vz, col) \
|
|
MTH3D_M_vSetMatrixColumnElements( MatDest, Vx, Vy, Vz, col)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_xGetMatrixElement
|
|
DESCRIPTION : Return element at (lin, col) in MatASet
|
|
INPUT : MatA : address of sw_3D_tdstMatrix
|
|
lin, col : int
|
|
OUTPUT : a : SCA_td_sw
|
|
=======================================================================================*/
|
|
#define sw_3D_M_xGetMatrixElement( lin, col, MatA) MTH3D_M_xGetMatrixElement( lin, col, MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vSetMatrixElement
|
|
DESCRIPTION : Set a element in MatDest at (lin, col)
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
a : SCA_td_sw
|
|
lin, col : int
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vSetMatrixElement( MatDest, a, lin, col) MTH3D_M_vSetMatrixElement( MatDest, a, lin, col)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vSetMatrixCol0Elements
|
|
DESCRIPTION : Set x, y, z values of column 0 in MatDest
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
Vx, Vy, Vz : SCA_td_sw
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vSetMatrixCol0Elements( MatDest, Vx, Vy, Vz) \
|
|
MTH3D_M_vSetMatrixCol0Elements( MatDest, Vx, Vy, Vz)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vSetMatrixCol1Elements
|
|
DESCRIPTION : Set x, y, z values of column 1 in MatDest
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
Vx, Vy, Vz : SCA_td_sw
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vSetMatrixCol1Elements( MatDest, Vx, Vy, Vz) \
|
|
MTH3D_M_vSetMatrixCol1Elements( MatDest, Vx, Vy, Vz)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vSetMatrixCol2Elements
|
|
DESCRIPTION : Set x, y, z values of column 2 in MatDest
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
Vx, Vy, Vz : SCA_td_sw
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vSetMatrixCol2Elements( MatDest, Vx, Vy, Vz) \
|
|
MTH3D_M_vSetMatrixCol2Elements( MatDest, Vx, Vy, Vz)
|
|
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vSetMatrixLineXElements
|
|
DESCRIPTION : Set x elements of all columns in MatDest
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
V0, V0, V0 : SCA_td_sw
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vSetMatrixLineXElements( MatDest, V0, V1, V2) \
|
|
MTH3D_M_vSetMatrixLineXElements( MatDest, V0, V1, V2)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vSetMatrixLineYElements
|
|
DESCRIPTION : Set y elements of all columns in MatDest
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
V0, V0, V0 : SCA_td_sw
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vSetMatrixLineYElements( MatDest, V0, V1, V2) \
|
|
MTH3D_M_vSetMatrixLineYElements( MatDest, V0, V1, V2)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vSetMatrixLineZElements
|
|
DESCRIPTION : Set z elements of all columns in MatDest
|
|
INPUT : MatDest : address of sw_3D_tdstMatrix
|
|
V0, V0, V0 : SCA_td_sw
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vSetMatrixLineZElements( MatDest, V0, V1, V2) \
|
|
MTH3D_M_vSetMatrixLineZElements( MatDest, V0, V1, V2)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vGetMatrixCol0Elements
|
|
DESCRIPTION : Get x, y, z values of column 0 in MatA
|
|
Vx, Vy, Vz : SCA_td_sw
|
|
INPUT : MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vGetMatrixCol0Elements( Vx, Vy, Vz, MatA) \
|
|
MTH3D_M_vGetMatrixCol0Elements( Vx, Vy, Vz, MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vGetMatrixCol1Elements
|
|
DESCRIPTION : Get x, y, z values of column 1 in MatA
|
|
Vx, Vy, Vz : SCA_td_sw
|
|
INPUT : MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vGetMatrixCol1Elements( Vx, Vy, Vz, MatA) \
|
|
MTH3D_M_vGetMatrixCol1Elements( Vx, Vy, Vz, MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vGetMatrixCol2Elements
|
|
DESCRIPTION : Get x, y, z values of column 2 in MatA
|
|
Vx, Vy, Vz : SCA_td_sw
|
|
INPUT : MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vGetMatrixCol2Elements( Vx, Vy, Vz, MatA) \
|
|
MTH3D_M_vGetMatrixCol2Elements( Vx, Vy, Vz, MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vGetMatrixLineXElements
|
|
DESCRIPTION : Get x elements of all columns in MatA
|
|
V0, V0, V0 : SCA_td_sw
|
|
INPUT : MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vGetMatrixLineXElements( V0, V1, V2, MatA) \
|
|
MTH3D_M_vGetMatrixLineXElements( V0, V1, V2, MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vGetMatrixLineYElements
|
|
DESCRIPTION : Get y elements of all columns in MatA
|
|
V0, V0, V0 : SCA_td_sw
|
|
INPUT : MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vGetMatrixLineYElements( V0, V1, V2, MatA) \
|
|
MTH3D_M_vGetMatrixLineYElements( V0, V1, V2, MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vGetMatrixLineZElements
|
|
DESCRIPTION : Get z elements of all columns in MatA
|
|
V0, V0, V0 : SCA_td_sw
|
|
INPUT : MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
#define sw_3D_M_vGetMatrixLineZElements( V0, V1, V2, MatA) \
|
|
MTH3D_M_vGetMatrixLineZElements( V0, V1, V2, MatA)
|
|
|
|
/* ##M==================================================================================
|
|
NAME : Pf2_sw
|
|
DESCRIPTION : Print a Vector : Name + its values
|
|
INPUT : Name : string
|
|
VectA : address of sw_3D_tdstVector
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
__inline void Pf2_sw(td_sw _xValue)
|
|
{
|
|
printf( " %e",_xValue );
|
|
}
|
|
|
|
/* ##M==================================================================================
|
|
NAME : sw_3D_M_vPrintfMatrix
|
|
DESCRIPTION : Print a Matrix : Name + its values
|
|
INPUT : Name : string
|
|
MatA : address of sw_3D_tdstMatrix
|
|
OUTPUT : void
|
|
=======================================================================================*/
|
|
|
|
__inline sw_3D_fn_vPrintfMatrix( char * Name, sw_3D_tdstMatrix * MatA) \
|
|
{
|
|
MTH3D_M_vPrintfMatrix( Name, MatA );
|
|
}
|
|
|
|
#define sw_3D_M_vPrintfMatrix( Name, MatA) sw_3D_fn_vPrintfMatrix( Name, MatA)
|
|
|
|
#endif /* __MATRICES_SW_3D__ */
|