plastimatch
Loading...
Searching...
No Matches
Macros | Functions
plm_math.h File Reference
#include <float.h>
#include <math.h>
#include <string.h>
#include <limits>
#include "compiler_warnings.h"

Go to the source code of this file.

Macros

#define M_PI   3.14159265358979323846
 
#define M_SQRT2   1.41421356237309504880
 
#define M_SQRTPI   1.77245385090551602792981
 
#define M_TWOPI   (M_PI * 2.0)
 
#define DBL_MAX   (1E+37)
 
#define M_SQRT1_2   0.70710678118654752440 /* 1/sqrt(2) */
 
#define M_SQRT3_OVER_2   0.866025403784439 /* sqrt(3)/2 - nonstandard */
 
#define M_SQRT2PI   2.50662827463100 /* sqrt(2*pi) - nonstandard */
 
#define M_PI_2   1.57079632679489661923 /* pi/2 */
 
#define M_PI_3   1.04719755119660 /* pi/3 - nonstandard */
 
#define M_PI_4   0.78539816339744830962 /* pi/4 */
 
#define ROUND_INT(x)   (((x) >= 0) ? ((long)((x)+0.5)) : (long)(-(-(x)+0.5)))
 
#define FLOOR_PLM_LONG(x)   ((plm_long) floor (x))
 
#define ROUND_PLM_LONG(x)    (((x) >= 0) ? ((plm_long)((x)+0.5)) : (plm_long)(-(-(x)+0.5)))
 
#define FLOOR_SIZE_T(x)   (((x) >= 0) ? ((size_t)(x)) : 0)
 
#define ROUND_SIZE_T(x)   (((x) >= 0) ? ((size_t)((x)+0.5)) : 0)
 
#define ROUND(x)   ((double) (ROUND_INT(x)))
 
#define SIGN(x)   (((x) >= 0) ? (+1) : (-1))
 
#define FLOAT_SMALL_VECTOR_LENGTH   1e-6
 
#define m_idx(m1, c, i, j)   m1[i*c+j]
 
#define NLMIN(T)   (-std::numeric_limits<T>::max())
 
#define NLMAX(T)   std::numeric_limits<T>::max()
 

Functions

static double exp10_ (double m)
 
static void vec2_add2 (double *v1, const double *v2)
 
static void vec3_add2 (double *v1, const double *v2)
 
static void vec3_add3 (double *v1, const double *v2, const double *v3)
 
template<class T >
static void vec3_add (T *v1, const T *v2)
 
template<class T >
static void vec3_add (T *v1, const T *v2, const T *v3)
 
template<class T >
static void vec3_copy (T *v1, const T *v2)
 
static void vec4_copy (double *v1, const double *v2)
 
template<class T >
static T vec3_dot (const T *v1, const T *v2)
 
template<class T , class U >
static float vec3_dot (const T *v1, const U *v2)
 
static double vec4_dot (const double *v1, const double *v2)
 
static void vec3_scale2 (double *v1, double a)
 
template<class T , class U >
static void vec3_scale3 (T *v1, const T *v2, U a)
 
template<class T >
static void vec3_sub2 (T *v1, const T *v2)
 
template<class T , class U , class V >
static void vec3_sub3 (T *v1, const U *v2, const V *v3)
 
static void vec3_invert (double *v1)
 
static void vec_zero (double *v1, int n)
 
template<class T >
static T vec3_lensq (const T *v1)
 
template<class T >
static T vec3_len (const T *)
 
template<>
double vec3_len (const double *v1)
 
template<>
float vec3_len< float > (const float *v1)
 
static void vec3_normalize1 (double *v1)
 
template<class T >
static T vec3_distsq (const T *v1, const T *v2)
 
template<class T >
static T vec3_dist (const T *v1, const T *v2)
 
template<class T >
static void vec3_cross (T *v1, const T *v2, const T *v3)
 
static void vec_outer (double *v1, const double *v2, const double *v3, const int n)
 
static void mat43_mult_vec4 (double *v1, const double *m2, const double *v3)
 
static void mat_mult_mat (double *m1, const double *m2, int m2_rows, int m2_cols, const double *m3, int m3_rows, int m3_cols)
 
static int is_number (const double x)
 
template<class T >
T clamp (T value, T min_value, T max_value)
 
template<class T >
T plm_max (T v1, T v2)
 
template<class T >
T plm_min (T v1, T v2)
 
template<class T >
T radians_from_degrees (T degrees)
 
static bool within_abs_tolerance (float value, float comp_value, float tolerance)
 

Macro Definition Documentation

◆ DBL_MAX

#define DBL_MAX   (1E+37)

◆ FLOAT_SMALL_VECTOR_LENGTH

#define FLOAT_SMALL_VECTOR_LENGTH   1e-6

◆ FLOOR_PLM_LONG

#define FLOOR_PLM_LONG (   x)    ((plm_long) floor (x))

◆ FLOOR_SIZE_T

#define FLOOR_SIZE_T (   x)    (((x) >= 0) ? ((size_t)(x)) : 0)

◆ m_idx

#define m_idx (   m1,
  c,
  i,
  j 
)    m1[i*c+j]

◆ M_PI

#define M_PI   3.14159265358979323846

◆ M_PI_2

#define M_PI_2   1.57079632679489661923 /* pi/2 */

◆ M_PI_3

#define M_PI_3   1.04719755119660 /* pi/3 - nonstandard */

◆ M_PI_4

#define M_PI_4   0.78539816339744830962 /* pi/4 */

◆ M_SQRT1_2

#define M_SQRT1_2   0.70710678118654752440 /* 1/sqrt(2) */

◆ M_SQRT2

#define M_SQRT2   1.41421356237309504880

◆ M_SQRT2PI

#define M_SQRT2PI   2.50662827463100 /* sqrt(2*pi) - nonstandard */

◆ M_SQRT3_OVER_2

#define M_SQRT3_OVER_2   0.866025403784439 /* sqrt(3)/2 - nonstandard */

◆ M_SQRTPI

#define M_SQRTPI   1.77245385090551602792981

◆ M_TWOPI

#define M_TWOPI   (M_PI * 2.0)

◆ NLMAX

#define NLMAX (   T)    std::numeric_limits<T>::max()

◆ NLMIN

#define NLMIN (   T)    (-std::numeric_limits<T>::max())

◆ ROUND

#define ROUND (   x)    ((double) (ROUND_INT(x)))

◆ ROUND_INT

#define ROUND_INT (   x)    (((x) >= 0) ? ((long)((x)+0.5)) : (long)(-(-(x)+0.5)))

◆ ROUND_PLM_LONG

#define ROUND_PLM_LONG (   x)     (((x) >= 0) ? ((plm_long)((x)+0.5)) : (plm_long)(-(-(x)+0.5)))

◆ ROUND_SIZE_T

#define ROUND_SIZE_T (   x)    (((x) >= 0) ? ((size_t)((x)+0.5)) : 0)

◆ SIGN

#define SIGN (   x)    (((x) >= 0) ? (+1) : (-1))

Function Documentation

◆ clamp()

template<class T >
T clamp ( T  value,
T  min_value,
T  max_value 
)

◆ exp10_()

static double exp10_ ( double  m)
inlinestatic

◆ is_number()

static int is_number ( const double  x)
inlinestatic

◆ mat43_mult_vec4()

static void mat43_mult_vec4 ( double v1,
const double m2,
const double v3 
)
inlinestatic

◆ mat_mult_mat()

static void mat_mult_mat ( double m1,
const double m2,
int  m2_rows,
int  m2_cols,
const double m3,
int  m3_rows,
int  m3_cols 
)
inlinestatic

◆ plm_max()

template<class T >
T plm_max ( T  v1,
T  v2 
)

◆ plm_min()

template<class T >
T plm_min ( T  v1,
T  v2 
)

◆ radians_from_degrees()

template<class T >
T radians_from_degrees ( T  degrees)

◆ vec2_add2()

static void vec2_add2 ( double v1,
const double v2 
)
inlinestatic

◆ vec3_add() [1/2]

template<class T >
static void vec3_add ( T v1,
const T v2 
)
inlinestatic

◆ vec3_add() [2/2]

template<class T >
static void vec3_add ( T v1,
const T v2,
const T v3 
)
inlinestatic

◆ vec3_add2()

static void vec3_add2 ( double v1,
const double v2 
)
inlinestatic

◆ vec3_add3()

static void vec3_add3 ( double v1,
const double v2,
const double v3 
)
inlinestatic

◆ vec3_copy()

template<class T >
static void vec3_copy ( T v1,
const T v2 
)
inlinestatic

◆ vec3_cross()

template<class T >
static void vec3_cross ( T v1,
const T v2,
const T v3 
)
inlinestatic

◆ vec3_dist()

template<class T >
static T vec3_dist ( const T v1,
const T v2 
)
inlinestatic

◆ vec3_distsq()

template<class T >
static T vec3_distsq ( const T v1,
const T v2 
)
inlinestatic

◆ vec3_dot() [1/2]

template<class T >
static T vec3_dot ( const T v1,
const T v2 
)
inlinestatic

◆ vec3_dot() [2/2]

template<class T , class U >
static float vec3_dot ( const T v1,
const U v2 
)
inlinestatic

◆ vec3_invert()

static void vec3_invert ( double v1)
inlinestatic

◆ vec3_len() [1/2]

template<>
double vec3_len ( const double v1)
inline

◆ vec3_len() [2/2]

template<class T >
static T vec3_len ( const T )
static

◆ vec3_len< float >()

template<>
float vec3_len< float > ( const float v1)
inline

◆ vec3_lensq()

template<class T >
static T vec3_lensq ( const T v1)
inlinestatic

◆ vec3_normalize1()

static void vec3_normalize1 ( double v1)
inlinestatic

◆ vec3_scale2()

static void vec3_scale2 ( double v1,
double  a 
)
inlinestatic

◆ vec3_scale3()

template<class T , class U >
static void vec3_scale3 ( T v1,
const T v2,
U  a 
)
inlinestatic

◆ vec3_sub2()

template<class T >
static void vec3_sub2 ( T v1,
const T v2 
)
inlinestatic

◆ vec3_sub3()

template<class T , class U , class V >
static void vec3_sub3 ( T v1,
const U v2,
const V v3 
)
inlinestatic

◆ vec4_copy()

static void vec4_copy ( double v1,
const double v2 
)
inlinestatic

◆ vec4_dot()

static double vec4_dot ( const double v1,
const double v2 
)
inlinestatic

◆ vec_outer()

static void vec_outer ( double v1,
const double v2,
const double v3,
const int  n 
)
inlinestatic

◆ vec_zero()

static void vec_zero ( double v1,
int  n 
)
inlinestatic

◆ within_abs_tolerance()

static bool within_abs_tolerance ( float  value,
float  comp_value,
float  tolerance 
)
inlinestatic