include/shape/ssi/ssi_math.hpp File Reference

#include <algorithm>
#include <math.h>

Go to the source code of this file.

Functions


Function Documentation

K abs ( const K &  k  )  [inline]
K det22 ( const K &  a,
const K &  b,
const K &  c,
const K &  d 
) [inline]

Definition at line 10 of file ssi_math.hpp.

00012 { return a*d - b*c; };

K det33 ( const K &  a00,
const K &  a01,
const K &  a02,
const K &  a10,
const K &  a11,
const K &  a12,
const K &  a20,
const K &  a21,
const K &  a22 
) [inline]

Definition at line 61 of file ssi_math.hpp.

References tcoff33().

00064       {
00065         K tmp[9];
00066         tcoff33( tmp[0], tmp[1], tmp[2],
00067                  tmp[3], tmp[4], tmp[5],
00068                  tmp[6], tmp[7], tmp[8],
00069                  a00,    a01,    a02, 
00070                  a10,    a11,    a12,
00071                  a20,    a21,    a22 );
00072         return   a00 * tmp[0] + a10 * tmp[1] + a20 * tmp[2];
00073       };

void inv33 ( K &  r00,
K &  r01,
K &  r02,
K &  r10,
K &  r11,
K &  r12,
K &  r20,
K &  r21,
K &  r22,
const K &  a00,
const K &  a01,
const K &  a02,
const K &  a10,
const K &  a11,
const K &  a12,
const K &  a20,
const K &  a21,
const K &  a22 
) [inline]

Definition at line 34 of file ssi_math.hpp.

References tcoff33().

00041       {
00042         tcoff33( r00, r01, r02, 
00043                  r10, r11, r12,
00044                  r20, r21, r22,
00045                  a00, a01, a02,
00046                  a10, a11, a12,
00047                  a20, a21, a22 );
00048         K idet = 1.0/(a00*r00+a10*r01+a20*r02);
00049         r00 *= idet;
00050         r01 *= idet;
00051         r02 *= idet;
00052         r10 *= idet;
00053         r11 *= idet;
00054         r12 *= idet;
00055         r20 *= idet;
00056         r21 *= idet;
00057         r22 *= idet;
00058       };

float Sqrt ( const float &  x,
const float &  prec 
) [inline]

Definition at line 91 of file ssi_math.hpp.

References sqrt().

00091 { return sqrt(x); };

double Sqrt ( const double &  x,
const double &  prec 
) [inline]

Definition at line 89 of file ssi_math.hpp.

References sqrt().

00089 { return sqrt(x); };

K Sqrt ( const K &  x,
const K &  prec = 1e-19 
) [inline]

Definition at line 76 of file ssi_math.hpp.

References abs().

00077       {
00078         
00079         K r  = x/2;
00080         do 
00081           {
00082             r  = (r+(x/r))/2;
00083           }
00084         while( abs(r*r-x) > prec );
00085         return r;
00086       };

void tcoff33 ( K &  r00,
K &  r01,
K &  r02,
K &  r10,
K &  r11,
K &  r12,
K &  r20,
K &  r21,
K &  r22,
const K &  a00,
const K &  a01,
const K &  a02,
const K &  a10,
const K &  a11,
const K &  a12,
const K &  a20,
const K &  a21,
const K &  a22 
) [inline]

Definition at line 15 of file ssi_math.hpp.

Referenced by det33(), and inv33().

00021 {
00022         r00 = a11*a22-a12*a21;
00023         r01 = -a01*a22+a02*a21;
00024         r02 = a01*a12-a02*a11;
00025         r10 = -a10*a22+a12*a20;
00026         r11 = a00*a22-a02*a20;
00027         r12 = -a00*a12+a02*a10;
00028         r20 = a10*a21-a11*a20;
00029         r21 = -a00*a21+a01*a20;
00030         r22 = a00*a11-a01*a10;
00031       };


Generated on 6 Dec 2012 for shape by  doxygen 1.6.1