Pyrogenesis  trunk
Macros | Functions | Variables
Decompose.cpp File Reference
#include "precompiled.h"
#include <math.h>
#include "Decompose.h"
Include dependency graph for Decompose.cpp:

Macros

#define mat_pad(A)   (A[W][X]=A[X][W]=A[W][Y]=A[Y][W]=A[W][Z]=A[Z][W]=0,A[W][W]=1)
 Fill out 3x3 matrix to 4x4. More...
 
#define mat_copy(C, gets, A, n)
 Copy nxn matrix A to C using "gets" for assignment. More...
 
#define mat_tpose(AT, gets, A, n)
 Copy transpose of nxn matrix A to C using "gets" for assignment. More...
 
#define mat_binop(C, gets, A, op, B, n)
 Assign nxn matrix C the element-wise combination of A and B using "op". More...
 
#define caseMacro(i, j, k, I, J, K)
 
#define TOL   1.0e-6
 
#define SQRTHALF   (0.7071067811865475244)
 
#define sgn(n, v)   ((n)?-(v):(v))
 
#define swap(a, i, j)   {a[3]=a[i]; a[i]=a[j]; a[j]=a[3];}
 
#define cycle(a, p)
 

Functions

void mat_mult (HMatrix A, HMatrix B, HMatrix AB)
 Multiply the upper left 3x3 parts of A and B to get AB. More...
 
float vdot (float *va, float *vb)
 Return dot product of length 3 vectors va and vb. More...
 
void vcross (float *va, float *vb, float *v)
 Set v to cross product of length 3 vectors va and vb. More...
 
void adjoint_transpose (HMatrix M, HMatrix MadjT)
 Set MadjT to transpose of inverse of M times determinant of M. More...
 
Quat Qt_ (float x, float y, float z, float w)
 
Quat Qt_Conj (Quat q)
 
Quat Qt_Mul (Quat qL, Quat qR)
 
Quat Qt_Scale (Quat q, float w)
 
Quat Qt_FromMatrix (HMatrix mat)
 
float mat_norm (HMatrix M, int tpose)
 Compute either the 1 or infinity norm of M, depending on tpose. More...
 
float norm_inf (HMatrix M)
 
float norm_one (HMatrix M)
 
int find_max_col (HMatrix M)
 Return index of column of M containing maximum abs entry, or -1 if M=0. More...
 
void make_reflector (float *v, float *u)
 Setup u for Household reflection to zero all v components but first. More...
 
void reflect_cols (HMatrix M, float *u)
 Apply Householder reflection represented by u to column vectors of M. More...
 
void reflect_rows (HMatrix M, float *u)
 Apply Householder reflection represented by u to row vectors of M. More...
 
void do_rank1 (HMatrix M, HMatrix Q)
 Find orthogonal factor Q of rank 1 (or less) M. More...
 
void do_rank2 (HMatrix M, HMatrix MadjT, HMatrix Q)
 Find orthogonal factor Q of rank 2 (or less) M using adjoint transpose. More...
 
float polar_decomp (HMatrix M, HMatrix Q, HMatrix S)
 
HVect spect_decomp (HMatrix S, HMatrix U)
 
Quat snuggle (Quat q, HVect *k)
 
void decomp_affine (HMatrix A, AffineParts *parts)
 
void invert_affine (AffineParts *parts, AffineParts *inverse)
 

Variables

static HMatrix mat_id = {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}}
 

Macro Definition Documentation

◆ caseMacro

#define caseMacro (   i,
  j,
  k,
  I,
  J,
 
)
Value:
case I:\
s = sqrt( (mat[I][I] - (mat[J][J]+mat[K][K])) + mat[W][W] );\
qu.i = s*0.5;\
s = 0.5 / s;\
qu.j = (mat[I][J] + mat[J][I]) * s;\
qu.k = (mat[K][I] + mat[I][K]) * s;\
qu.w = (mat[K][J] - mat[J][K]) * s;\
break
Definition: Decompose.h:22

◆ cycle

#define cycle (   a,
 
)
Value:
if (p) {a[3]=a[0]; a[0]=a[1]; a[1]=a[2]; a[2]=a[3];}\
else {a[3]=a[2]; a[2]=a[1]; a[1]=a[0]; a[0]=a[3];}

◆ mat_binop

#define mat_binop (   C,
  gets,
  A,
  op,
  B,
 
)
Value:
{for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j)\
C[i][j] gets (A[i][j]) op (B[i][j]);}

Assign nxn matrix C the element-wise combination of A and B using "op".

◆ mat_copy

#define mat_copy (   C,
  gets,
  A,
 
)
Value:
{for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j)\
C[i][j] gets (A[i][j]);}

Copy nxn matrix A to C using "gets" for assignment.

◆ mat_pad

#define mat_pad (   A)    (A[W][X]=A[X][W]=A[W][Y]=A[Y][W]=A[W][Z]=A[Z][W]=0,A[W][W]=1)

Fill out 3x3 matrix to 4x4.

◆ mat_tpose

#define mat_tpose (   AT,
  gets,
  A,
 
)
Value:
{for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j)\
AT[i][j] gets (A[j][i]);}
#define AT(x)

Copy transpose of nxn matrix A to C using "gets" for assignment.

◆ sgn

#define sgn (   n,
 
)    ((n)?-(v):(v))

◆ SQRTHALF

#define SQRTHALF   (0.7071067811865475244)

◆ swap

#define swap (   a,
  i,
 
)    {a[3]=a[i]; a[i]=a[j]; a[j]=a[3];}

◆ TOL

#define TOL   1.0e-6

Function Documentation

◆ adjoint_transpose()

void adjoint_transpose ( HMatrix  M,
HMatrix  MadjT 
)

Set MadjT to transpose of inverse of M times determinant of M.

◆ decomp_affine()

void decomp_affine ( HMatrix  A,
AffineParts parts 
)

◆ do_rank1()

void do_rank1 ( HMatrix  M,
HMatrix  Q 
)

Find orthogonal factor Q of rank 1 (or less) M.

◆ do_rank2()

void do_rank2 ( HMatrix  M,
HMatrix  MadjT,
HMatrix  Q 
)

Find orthogonal factor Q of rank 2 (or less) M using adjoint transpose.

◆ find_max_col()

int find_max_col ( HMatrix  M)

Return index of column of M containing maximum abs entry, or -1 if M=0.

◆ invert_affine()

void invert_affine ( AffineParts parts,
AffineParts inverse 
)

◆ make_reflector()

void make_reflector ( float *  v,
float *  u 
)

Setup u for Household reflection to zero all v components but first.

◆ mat_mult()

void mat_mult ( HMatrix  A,
HMatrix  B,
HMatrix  AB 
)

Multiply the upper left 3x3 parts of A and B to get AB.

◆ mat_norm()

float mat_norm ( HMatrix  M,
int  tpose 
)

Compute either the 1 or infinity norm of M, depending on tpose.

◆ norm_inf()

float norm_inf ( HMatrix  M)

◆ norm_one()

float norm_one ( HMatrix  M)

◆ polar_decomp()

float polar_decomp ( HMatrix  M,
HMatrix  Q,
HMatrix  S 
)

◆ Qt_()

Quat Qt_ ( float  x,
float  y,
float  z,
float  w 
)

◆ Qt_Conj()

Quat Qt_Conj ( Quat  q)

◆ Qt_FromMatrix()

Quat Qt_FromMatrix ( HMatrix  mat)

◆ Qt_Mul()

Quat Qt_Mul ( Quat  qL,
Quat  qR 
)

◆ Qt_Scale()

Quat Qt_Scale ( Quat  q,
float  w 
)

◆ reflect_cols()

void reflect_cols ( HMatrix  M,
float *  u 
)

Apply Householder reflection represented by u to column vectors of M.

◆ reflect_rows()

void reflect_rows ( HMatrix  M,
float *  u 
)

Apply Householder reflection represented by u to row vectors of M.

◆ snuggle()

Quat snuggle ( Quat  q,
HVect k 
)

◆ spect_decomp()

HVect spect_decomp ( HMatrix  S,
HMatrix  U 
)

◆ vcross()

void vcross ( float *  va,
float *  vb,
float *  v 
)

Set v to cross product of length 3 vectors va and vb.

◆ vdot()

float vdot ( float *  va,
float *  vb 
)

Return dot product of length 3 vectors va and vb.

Variable Documentation

◆ mat_id

HMatrix mat_id = {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}}
static