Data Structures | Functions | Variables

Nytro::Math Namespace Reference

Mathematics utilitarian functions and classes. More...

Data Structures

class  AngleAxis
 The angle-axis rotation representation ( angle rotated around axis ). More...
class  Box
 An axis aligned 3D box. More...
class  Matrix
 A 4x4 matrix. More...
class  OrientedBox
 This is an oriented (rotated) bounding box, used for early collision tests. More...
class  Plane
 A 3D infinite plane. More...
class  Quaternion
 The mighty quaternion, holding rotation. More...
class  Ray
 A ray, stored as first point and direction. More...
class  Vector3D
 A 3D vector. More...

Functions

template<class T >
void swapValues (T &rA, T &rB)
 swap variables of any type
template<class T >
clampValue (T aA, T aMin, T aMax)
 clamp variables of any type
NYTRO_EXPORT float32 getCos2D (float32 x1, float32 y1, float32 x2, float32 y2)
NYTRO_EXPORT Vector3D getHermitePoint (Vector3D &rA, Vector3D &rAN, Vector3D &rBN, Vector3D &rB, float32 aTime)
 compute hermite point using control points rA,rB incoming tangent rAN, outgoing rBN, at interpolation point aTime [0..1]
NYTRO_EXPORT void getShadowMatrix (float32 aShadowMat[4][4], float32 aGroundPlane[4], float32 aLightPos[4])
 compute a shadow matrix
NYTRO_EXPORT void getReflectedPoint (Vector3D &rN, Vector3D &rL, Vector3D &rR)
NYTRO_EXPORT void getRefractedPoint (Vector3D &rN, Vector3D &rL, Vector3D &rR, float32 aCoef)
NYTRO_EXPORT void getProjectedPoint (Vector3D &rP1, Vector3D &rP2, Vector3D &rP3, Vector3D &rP, Vector3D &rProj)
NYTRO_EXPORT void setRandomSeed (int32 aSeed)
 set the random seed
NYTRO_EXPORT int32 getRandomInteger (int32 aMax)
NYTRO_EXPORT float32 getRandomFloat (float32 aLow, float32 aHigh)
NYTRO_EXPORT bool sphereIntersect (Vector3D &rSphereCenter1, Vector3D &rSphereCenter2, Vector3D &rVelocity1, Vector3D &rVelocity2, float32 aRadius1, float32 aRadius2, float32 &rTimeIn, float32 &rTimeOut)
 intersect spheres with centers aSphereCenter1 and aSphereCenter2, with velocities aVelocity1, aVelocity2, with radiuses aRadius1, aRadius2, into rTimeIn and rTimeOut
NYTRO_EXPORT bool triangleLineIntersect (Vector3D &rP1, Vector3D &rP2, Vector3D &rP3, Vector3D &rL1, Vector3D &rL2, Vector3D &rIntersection, float32 &rTime, bool bAcceptBackface=true)
 intersect triangle [rP1,rP2,rP3] and line [rL1,rL2], put into rIntersection the intersection point at rTime [0..1]
NYTRO_EXPORT bool lineLineIntersect (Vector3D &rLA1, Vector3D &rLA2, Vector3D &rLB1, Vector3D &rLB2, Vector3D &rL1, Vector3D &rL2, float32 &rT1, float32 &rT2, float32 aTolerance=0.0001)
 intersect two infinite 3D lines rLA1, rLB1 and rLA2, rLB2 resulting a segment rL1,rL2 which is the smallest segment between the two lines
it will also return the rT1 on line 1, and rT2 on line 2 (the actual rL1 and rL2), aTolerance is the error threshold used to detect intersection
NYTRO_EXPORT bool segmentSegmentIntersect (Vector3D &rLA1, Vector3D &rLA2, Vector3D &rLB1, Vector3D &rLB2, Vector3D &rL1, Vector3D &rL2, float32 &rT1, float32 &rT2, float32 aSmallestDistance=0, float32 aTolerance=0.0001)
 intersect two finite 3D segment lines rLA1, rLB1 and rLA2, rLB2 resulting a segment rL1,rL2 which is the smallest segment between the two lines
it will also return the rT1 on line 1, and rT2 on line 2 (the actual rL1 and rL2), aTolerance is the error threshold used to detect intersection
NYTRO_EXPORT bool linePolylineIntersect (Vector3D &rA, Vector3D &rB, vector< Vector3D > &rPolyline, float32 aSmallestDistance=1, float32 aTolerance=0.0001)
 intersect a line with a polyline
NYTRO_EXPORT float32 getEasedValue (float32 aPrevious, float32 aCurrent, float32 aNext, float32 aEaseFrom, float32 aEaseTo)
 ease a value
NYTRO_EXPORT float32 getRandomNormalizedFloat ()
NYTRO_EXPORT Vector3D getClosestPointOnLineSegment (Vector3D &rA, Vector3D &rB, Vector3D &rP, bool &rEdge)
NYTRO_EXPORT Vector3D getClosestPointOnLine (Vector3D &rA, Vector3D &rB, Vector3D &rP)
NYTRO_EXPORT bool isPointInsideEdge (Vector3D &rA, Vector3D &rB, Vector3D &rP)
NYTRO_EXPORT bool intersectRaySphere (Vector3D &rCenter, float32 aRadius, Ray &rRay, float32 &rHitTime, Vector3D &rHitPosIn, Vector3D &rHitPosOut)
 intersect a ray/line with a sphere

Variables

const float64 kConst_2PI = 6.283185307f
const float64 kConst_PI = 3.141592654f
const float64 kConst_HalfPI = 1.570796327f
const float64 kConst_Eps = 0.001f
const float64 kConst_Epsilon = 1.0e-6
const float64 kConst_PIOver180 = kConst_PI / 180.0f
const float64 kConst_180OverPI = 180.0f / kConst_PI
const float64 kConst_PIx180 = kConst_PI * 180.0f
const float32 kMeterUnit = 1.0f
 how many world units is 1 meter
const float32 kFeetUnit = kMeterUnit * 0.3048f
const float32 kOneKm = kMeterUnit*1000.0f
const float32 kOneMile = kOneKm*1.609344f
const float32 kOneNauticalMile = kOneKm*1.852f
const float64 M_PI = kConst_PI
const float64 PI = kConst_PI

Detailed Description

Mathematics utilitarian functions and classes.


Function Documentation

template<class T >
T Nytro::Math::clampValue ( aA,
aMin,
aMax 
) [inline]

clamp variables of any type

Definition at line 87 of file nyMath.h.

NYTRO_EXPORT Vector3D Nytro::Math::getClosestPointOnLine ( Vector3D &  rA,
Vector3D &  rB,
Vector3D &  rP 
)
Returns:
closest point on line
NYTRO_EXPORT Vector3D Nytro::Math::getClosestPointOnLineSegment ( Vector3D &  rA,
Vector3D &  rB,
Vector3D &  rP,
bool &  rEdge 
)
Returns:
the closest point on a limited line segment
NYTRO_EXPORT float32 Nytro::Math::getCos2D ( float32  x1,
float32  y1,
float32  x2,
float32  y2 
)
Returns:
the 2D cosinus (dot) between the lines formed by x1,y1 and x2,y2, with origin in 0,0
NYTRO_EXPORT float32 Nytro::Math::getEasedValue ( float32  aPrevious,
float32  aCurrent,
float32  aNext,
float32  aEaseFrom,
float32  aEaseTo 
)

ease a value

NYTRO_EXPORT Vector3D Nytro::Math::getHermitePoint ( Vector3D &  rA,
Vector3D &  rAN,
Vector3D &  rBN,
Vector3D &  rB,
float32  aTime 
)

compute hermite point using control points rA,rB incoming tangent rAN, outgoing rBN, at interpolation point aTime [0..1]

NYTRO_EXPORT void Nytro::Math::getProjectedPoint ( Vector3D &  rP1,
Vector3D &  rP2,
Vector3D &  rP3,
Vector3D &  rP,
Vector3D &  rProj 
)
Returns:
point rP projected onto plane made by rP1,rP2,rP3 into rProj
NYTRO_EXPORT float32 Nytro::Math::getRandomFloat ( float32  aLow,
float32  aHigh 
)
Returns:
a random float32 between aLow and aHigh
NYTRO_EXPORT int32 Nytro::Math::getRandomInteger ( int32  aMax  ) 
Returns:
a random integer smaller than aMax
NYTRO_EXPORT float32 Nytro::Math::getRandomNormalizedFloat (  ) 
Returns:
a random float32 between [0..1]
NYTRO_EXPORT void Nytro::Math::getReflectedPoint ( Vector3D &  rN,
Vector3D &  rL,
Vector3D &  rR 
)
Returns:
the reflected vector rL around normal rN into rR
NYTRO_EXPORT void Nytro::Math::getRefractedPoint ( Vector3D &  rN,
Vector3D &  rL,
Vector3D &  rR,
float32  aCoef 
)
Returns:
the refracted vector rL around normal rN, into rR, using refraction index aCoef
NYTRO_EXPORT void Nytro::Math::getShadowMatrix ( float32  aShadowMat[4][4],
float32  aGroundPlane[4],
float32  aLightPos[4] 
)

compute a shadow matrix

NYTRO_EXPORT bool Nytro::Math::intersectRaySphere ( Vector3D &  rCenter,
float32  aRadius,
Ray &  rRay,
float32 &  rHitTime,
Vector3D &  rHitPosIn,
Vector3D &  rHitPosOut 
)

intersect a ray/line with a sphere

NYTRO_EXPORT bool Nytro::Math::isPointInsideEdge ( Vector3D &  rA,
Vector3D &  rB,
Vector3D &  rP 
)
Returns:
true if point is inside an edge/line
NYTRO_EXPORT bool Nytro::Math::lineLineIntersect ( Vector3D &  rLA1,
Vector3D &  rLA2,
Vector3D &  rLB1,
Vector3D &  rLB2,
Vector3D &  rL1,
Vector3D &  rL2,
float32 &  rT1,
float32 &  rT2,
float32  aTolerance = 0.0001 
)

intersect two infinite 3D lines rLA1, rLB1 and rLA2, rLB2 resulting a segment rL1,rL2 which is the smallest segment between the two lines
it will also return the rT1 on line 1, and rT2 on line 2 (the actual rL1 and rL2), aTolerance is the error threshold used to detect intersection

NYTRO_EXPORT bool Nytro::Math::linePolylineIntersect ( Vector3D &  rA,
Vector3D &  rB,
vector< Vector3D > &  rPolyline,
float32  aSmallestDistance = 1,
float32  aTolerance = 0.0001 
)

intersect a line with a polyline

Returns:
true if the line touches one of the polyline's segments
NYTRO_EXPORT bool Nytro::Math::segmentSegmentIntersect ( Vector3D &  rLA1,
Vector3D &  rLA2,
Vector3D &  rLB1,
Vector3D &  rLB2,
Vector3D &  rL1,
Vector3D &  rL2,
float32 &  rT1,
float32 &  rT2,
float32  aSmallestDistance = 0,
float32  aTolerance = 0.0001 
)

intersect two finite 3D segment lines rLA1, rLB1 and rLA2, rLB2 resulting a segment rL1,rL2 which is the smallest segment between the two lines
it will also return the rT1 on line 1, and rT2 on line 2 (the actual rL1 and rL2), aTolerance is the error threshold used to detect intersection

NYTRO_EXPORT void Nytro::Math::setRandomSeed ( int32  aSeed  ) 

set the random seed

NYTRO_EXPORT bool Nytro::Math::sphereIntersect ( Vector3D &  rSphereCenter1,
Vector3D &  rSphereCenter2,
Vector3D &  rVelocity1,
Vector3D &  rVelocity2,
float32  aRadius1,
float32  aRadius2,
float32 &  rTimeIn,
float32 &  rTimeOut 
)

intersect spheres with centers aSphereCenter1 and aSphereCenter2, with velocities aVelocity1, aVelocity2, with radiuses aRadius1, aRadius2, into rTimeIn and rTimeOut

template<class T >
void Nytro::Math::swapValues ( T &  rA,
T &  rB 
) [inline]

swap variables of any type

Definition at line 79 of file nyMath.h.

NYTRO_EXPORT bool Nytro::Math::triangleLineIntersect ( Vector3D &  rP1,
Vector3D &  rP2,
Vector3D &  rP3,
Vector3D &  rL1,
Vector3D &  rL2,
Vector3D &  rIntersection,
float32 &  rTime,
bool  bAcceptBackface = true 
)

intersect triangle [rP1,rP2,rP3] and line [rL1,rL2], put into rIntersection the intersection point at rTime [0..1]


Variable Documentation

const float64 Nytro::Math::kConst_180OverPI = 180.0f / kConst_PI

Definition at line 38 of file nyMath.h.

const float64 Nytro::Math::kConst_2PI = 6.283185307f

Definition at line 32 of file nyMath.h.

Definition at line 35 of file nyMath.h.

Definition at line 36 of file nyMath.h.

const float64 Nytro::Math::kConst_HalfPI = 1.570796327f

Definition at line 34 of file nyMath.h.

const float64 Nytro::Math::kConst_PI = 3.141592654f

Definition at line 33 of file nyMath.h.

Definition at line 37 of file nyMath.h.

Definition at line 39 of file nyMath.h.

Definition at line 42 of file nyMath.h.

how many world units is 1 meter

Definition at line 41 of file nyMath.h.

Definition at line 43 of file nyMath.h.

Definition at line 44 of file nyMath.h.

Definition at line 45 of file nyMath.h.

Definition at line 48 of file nyMath.h.

Definition at line 52 of file nyMath.h.


© Copyright 7thFACTOR Entertainment - All rights reserved