summaryrefslogtreecommitdiffstats
path: root/src/math/old
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-06-12 13:48:17 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-06-12 13:48:17 +0200
commitb5d16ef340208bbe1a76f33f7498fb168f6405b6 (patch)
tree86b2f31585b0621130d9c5300a77f2be9c30c808 /src/math/old
parenta8665d204255b4b0ad9ae6982f77ecd5e053c1b6 (diff)
downloadcolobot-b5d16ef340208bbe1a76f33f7498fb168f6405b6.tar.gz
colobot-b5d16ef340208bbe1a76f33f7498fb168f6405b6.tar.bz2
colobot-b5d16ef340208bbe1a76f33f7498fb168f6405b6.zip
Fixes in math module
- rewritten RotateAngle() function and test for it in geometry_test.cpp - added conv.h - conversion functions - added comments in math3d.h and d3dmath.h pointing to new functions - other minor fixes
Diffstat (limited to 'src/math/old')
-rw-r--r--src/math/old/d3dmath.h10
-rw-r--r--src/math/old/math3d.h63
2 files changed, 72 insertions, 1 deletions
diff --git a/src/math/old/d3dmath.h b/src/math/old/d3dmath.h
index 0cab192..5d95290 100644
--- a/src/math/old/d3dmath.h
+++ b/src/math/old/d3dmath.h
@@ -47,6 +47,7 @@ const FLOAT g_EPSILON = 1.0e-5f; // Tolerance for FLOATs
//-----------------------------------------------------------------------------
// Fuzzy compares (within tolerance)
//-----------------------------------------------------------------------------
+//>>> func.h IsZero()
inline bool D3DMath_IsZero( FLOAT a, FLOAT fTol = g_EPSILON )
{ return ( a <= 0.0f ) ? ( a >= -fTol ) : ( a <= fTol ); }
@@ -56,7 +57,9 @@ inline bool D3DMath_IsZero( FLOAT a, FLOAT fTol = g_EPSILON )
//-----------------------------------------------------------------------------
// Matrix functions
//-----------------------------------------------------------------------------
+//>>> matrix.h MultiplyMatrices()
VOID D3DMath_MatrixMultiply( D3DMATRIX& q, D3DMATRIX& a, D3DMATRIX& b );
+//>>> matrix.h Matrix::Invert()
HRESULT D3DMath_MatrixInvert( D3DMATRIX& q, D3DMATRIX& a );
@@ -65,8 +68,11 @@ HRESULT D3DMath_MatrixInvert( D3DMATRIX& q, D3DMATRIX& a );
//-----------------------------------------------------------------------------
// Vector functions
//-----------------------------------------------------------------------------
+
+//>>> matrix.h MatrixVectorMultiply()
HRESULT D3DMath_VectorMatrixMultiply( D3DVECTOR& vDest, D3DVECTOR& vSrc,
D3DMATRIX& mat);
+// TODO
HRESULT D3DMath_VertexMatrixMultiply( D3DVERTEX& vDest, D3DVERTEX& vSrc,
D3DMATRIX& mat );
@@ -76,6 +82,10 @@ HRESULT D3DMath_VertexMatrixMultiply( D3DVERTEX& vDest, D3DVERTEX& vSrc,
//-----------------------------------------------------------------------------
// Quaternion functions
//-----------------------------------------------------------------------------
+
+// UNUSED
+
+
VOID D3DMath_QuaternionFromRotation( FLOAT& x, FLOAT& y, FLOAT& z, FLOAT& w,
D3DVECTOR& v, FLOAT fTheta );
VOID D3DMath_RotationFromQuaternion( D3DVECTOR& v, FLOAT& fTheta,
diff --git a/src/math/old/math3d.h b/src/math/old/math3d.h
index f08f9a6..cb17669 100644
--- a/src/math/old/math3d.h
+++ b/src/math/old/math3d.h
@@ -30,76 +30,137 @@
+//>>> func.h IsEqual()
bool IsEqual(float a, float b);
+//>>> func.h Min()
float Min(float a, float b);
float Min(float a, float b, float c);
float Min(float a, float b, float c, float d);
float Min(float a, float b, float c, float d, float e);
+//>>> func.h Max()
float Max(float a, float b);
float Max(float a, float b, float c);
float Max(float a, float b, float c, float d);
float Max(float a, float b, float c, float d, float e);
+//>>> func.h Norm()
float Norm(float a);
+//>>> fabs()
float Abs(float a);
-
+
+//>>> func.h Swap()
void Swap(int &a, int &b);
+//>>> func.h Swap()
void Swap(float &a, float &b);
+//>>> point.h Swap() (FPOINT -> Point)
void Swap(FPOINT &a, FPOINT &b);
+//>>> func.h Mod()
float Mod(float a, float m);
+//>>> func.h NormAngle()
float NormAngle(float angle);
+//>>> func.h TestAngle()
bool TestAngle(float angle, float min, float max);
+//>>> func.h Direction()
float Direction(float a, float g);
+//>>> geometry.h RotatePoint()
FPOINT RotatePoint(FPOINT center, float angle, FPOINT p);
+//>>> geometry.h RotatePoint()
FPOINT RotatePoint(float angle, FPOINT p);
+//>>> geometry.h RotatePoint()
FPOINT RotatePoint(float angle, float dist);
+//>>> geometry.h RotateAngle()
float RotateAngle(float x, float y);
+//>>> geometry.h RotateAngle()
float RotateAngle(FPOINT center, FPOINT p1, FPOINT p2);
+//>>> geometry.h MidPoint()
float MidPoint(FPOINT a, FPOINT b, float px);
+//>>> geometry.h SegmentPoint()
D3DVECTOR SegmentDist(const D3DVECTOR &p1, const D3DVECTOR &p2, float dist);
+//>>> geometry.h IsInsideTriangle()
bool IsInsideTriangle(FPOINT a, FPOINT b, FPOINT c, FPOINT p);
+//>>> geometry.h Intersect()
bool Intersect(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR d, D3DVECTOR e, D3DVECTOR &i);
+//>>> geometry.h IntersectY()
bool IntersectY(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR &p);
+//>>> geometry.h RotatePoint()
void RotatePoint(float cx, float cy, float angle, float &px, float &py);
+//>>> geometry.h RotatePoint()
void RotatePoint(D3DVECTOR center, float angleH, float angleV, D3DVECTOR &p);
+//>>> geometry.h RotatePoint2()
void RotatePoint2(D3DVECTOR center, float angleH, float angleV, D3DVECTOR &p);
+//>>> geometry.h RotateView()
+// TODO test & verify
D3DVECTOR RotateView(D3DVECTOR center, float angleH, float angleV, float dist);
+//>>> geometry.h LookatPoint()
+// TODO test & verify
D3DVECTOR LookatPoint( D3DVECTOR eye, float angleH, float angleV, float length );
+//>>> point.h Distance()
float Length(FPOINT a, FPOINT b);
+//>>> point.h Point::Length()
float Length(float x, float y);
+//>>> vector.h Vector::Length()
float Length(const D3DVECTOR &u);
+//>>> vector.h Distance()
float Length(const D3DVECTOR &a, const D3DVECTOR &b);
+//>>> geometry.h DistanceProjected()
float Length2d(const D3DVECTOR &a, const D3DVECTOR &b);
+//>>> vector.h Angle()
+// TODO test & verify
float Angle( D3DVECTOR u, D3DVECTOR v );
+//>>> vector.h CrossProduct()
D3DVECTOR Cross( D3DVECTOR u, D3DVECTOR v );
+//>>> geometry.h NormalToPlane()
D3DVECTOR ComputeNormal( D3DVECTOR p1, D3DVECTOR p2, D3DVECTOR p3 );
+//>>> geometry.h Transform()
+// TODO test & verify
D3DVECTOR Transform(const D3DMATRIX &m, D3DVECTOR p);
+//>>> geometry.h Projection()
+// TODO test & verify
D3DVECTOR Projection(const D3DVECTOR &a, const D3DVECTOR &b, const D3DVECTOR &p);
+// TODO
void MappingObject( D3DVERTEX2* pVertices, int nb, float scale );
+// TODO
void SmoothObject( D3DVERTEX2* pVertices, int nb );
+//>>> geometry.h LinearFunction()
bool LineFunction(FPOINT p1, FPOINT p2, float &a, float &b);
+//>>> geometry.h DistanceToPlane()
float DistancePlanPoint(const D3DVECTOR &a, const D3DVECTOR &b, const D3DVECTOR &c, const D3DVECTOR &p);
+//>>> geometry.h IsSamePlane()
bool IsSamePlane(D3DVECTOR *plan1, D3DVECTOR *plan2);
+//>>> geometry.h LoadRotationXZYMatrix()
+// TODO test & verify
void MatRotateXZY(D3DMATRIX &mat, D3DVECTOR angle);
+//>>> geometry.h LoadRotationZXYMatrix()
+// TODO test & verify
void MatRotateZXY(D3DMATRIX &mat, D3DVECTOR angle);
+//>>> func.h Rand()
float Rand();
+//>>> func.h Neutral()
float Neutral(float value, float dead);
+//>>> func.h PropAngle()
float Prop(int a, int b, float p);
+//>>> func.h Smooth()
float Smooth(float actual, float hope, float time);
+//>>> func.h Bounce()
float Bounce(float progress, float middle=0.3f, float bounce=0.4f);
+// TODO
D3DCOLOR RetColor(float intensity);
+// TODO
D3DCOLOR RetColor(D3DCOLORVALUE intensity);
+// TODO
D3DCOLORVALUE RetColor(D3DCOLOR intensity);
+// TODO
void RGB2HSV(D3DCOLORVALUE src, ColorHSV &dest);
+// TODO
void HSV2RGB(ColorHSV src, D3DCOLORVALUE &dest);