A 3D Dynamic Geometry Software

Calques 3D C++



3dmath.h File Reference


Detailed Description

Contains some useful math helpers for common 3D graphics entities.

In this file are implemented some mathematical entities often used in 3D graphics (vecors, points, etc.) plus some useful constants, macros and definitions

Version:
0.1
Date:
12/06/99
Author:
Alessandro Falappa


Classes

class  vector
 A vector class. More...
class  tmatrix
class  quaternion
class  unitquaternion

Defines

#define REAL_IS_DOUBLE
 defined when high precision is requested

Typedefs

typedef double real
 The base type for all the math helpers.

Functions

int operator== (const vector &v1, const vector &v2)
int operator!= (const vector &v1, const vector &v2)
void clamp (real &val, const real &low, const real &high)
real clamped (const real &val, const real &low, const real &high)
void clamp (vector &theVec, const real &low, const real &high)
real RadToDeg (const real &angle)
 returns angle expressed in degrees.
real DegToRad (const real &angle)
 returns angle expressed in radians.
void ConvertToDeg (real &angle)
 converts radiants to degrees. This function modify its argument.
void ConvertToRad (real &angle)
 converts degrees to radiants. This function modify its argument.
real simpleabs (const real &val)
 absolute value function which executes a simple test This function executes a simple test on val negativity returning the opposite if true. Such a test can be faster than the call to the fabs library routine

Variables

const real epsilon = 1e-12
 the treshold for comparisons with zero, mainly used to avoid division by zero errors
const vector ORIGIN
 the vector representing the origin
const vector X_AXIS
 the unit vector associated to the x axys
const vector Y_AXIS
 the unit vector associated to the y axys
const vector Z_AXIS
 the unit vector associated to the z axys
const real G_PI
 the greek pi constant
const real G_HALF_PI
 greek pi / 2
const real G_DOUBLE_PI
 2 * greek pi

Define Documentation

#define REAL_IS_DOUBLE

defined when high precision is requested


Typedef Documentation

typedef double real

The base type for all the math helpers.


Function Documentation

void clamp ( vector theVec,
const real low,
const real high 
) [inline]

limits the vector components in a range, modifying it.

Parameters:
theVec the vector to clamp
low the lower treshold
high the higher treshold

void clamp ( real val,
const real low,
const real high 
) [inline]

limits a value in a range, modifying it.

Parameters:
val the value to clamp
low the lower treshold
high the higher treshold

real clamped ( const real val,
const real low,
const real high 
) [inline]

limits a value in a range, returning the clamped value.

Returns:
the clamped value
Parameters:
val the value to clamp
low the lower treshold
high the higher treshold

void ConvertToDeg ( real angle  )  [inline]

converts radiants to degrees. This function modify its argument.

Parameters:
angle the angle to be converted

void ConvertToRad ( real angle  )  [inline]

converts degrees to radiants. This function modify its argument.

Parameters:
angle the angle to be converted

real DegToRad ( const real angle  )  [inline]

returns angle expressed in radians.

Returns:
the angle expresses in degrees
Parameters:
angle the angle value

int operator!= ( const vector v1,
const vector v2 
) [inline]

This function check if some of the elements of v1 differs from the corresponding elements of v2.

int operator== ( const vector v1,
const vector v2 
) [inline]

This function check if all elements of v1 are equal to the corresponding elements of v2.

real RadToDeg ( const real angle  )  [inline]

returns angle expressed in degrees.

Returns:
the angle expresses in radians
Parameters:
angle the angle value
Author:
Alessandro Falappa

real simpleabs ( const real val  )  [inline]

absolute value function which executes a simple test This function executes a simple test on val negativity returning the opposite if true. Such a test can be faster than the call to the fabs library routine

Returns:
the absolute value of val


Variable Documentation

const real epsilon = 1e-12

the treshold for comparisons with zero, mainly used to avoid division by zero errors

2 * greek pi

const real G_HALF_PI

greek pi / 2

const real G_PI

the greek pi constant

const vector ORIGIN

the vector representing the origin

const vector X_AXIS

the unit vector associated to the x axys

const vector Y_AXIS

the unit vector associated to the y axys

const vector Z_AXIS

the unit vector associated to the z axys