summaryrefslogtreecommitdiffstats
path: root/src/math
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-06-19 20:11:47 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-06-19 20:11:47 +0200
commit9f784e81f81651bed087902f9f3afee113e56148 (patch)
treeae89f6dabe2443b39aba292673027d197fc120e6 /src/math
parentb8027ce9a7f050b95846a668a02f5801331e127f (diff)
downloadcolobot-9f784e81f81651bed087902f9f3afee113e56148.tar.gz
colobot-9f784e81f81651bed087902f9f3afee113e56148.tar.bz2
colobot-9f784e81f81651bed087902f9f3afee113e56148.zip
Switched to new implementation of the rest of math module
- changed structs from D3DVECTOR to Math::Vector and from D3DMATRIX to Math::Matrix - changed functions to new Math namespace functions - moved mainmovie module from graphics to object - added Get and Set to Math::Matrix
Diffstat (limited to 'src/math')
-rw-r--r--src/math/matrix.h10
-rw-r--r--src/math/old/math3d.cpp59
-rw-r--r--src/math/old/math3d.h65
3 files changed, 69 insertions, 65 deletions
diff --git a/src/math/matrix.h b/src/math/matrix.h
index 5b098d7..35871cf 100644
--- a/src/math/matrix.h
+++ b/src/math/matrix.h
@@ -91,6 +91,16 @@ struct Matrix
}
}
+ inline void Set(int row, int col, float value)
+ {
+ m[(col-1)*4+(row-1)] = value;
+ }
+
+ inline float Get(int row, int col)
+ {
+ return m[(col-1)*4+(row-1)];
+ }
+
//! Loads the zero matrix
inline void LoadZero()
{
diff --git a/src/math/old/math3d.cpp b/src/math/old/math3d.cpp
index 05154fe..a9d67f2 100644
--- a/src/math/old/math3d.cpp
+++ b/src/math/old/math3d.cpp
@@ -125,6 +125,65 @@ float Smooth(float actual, float hope, float time);
float Bounce(float progress, float middle=0.3f, float bounce=0.4f);
+//>>> geometry.h SegmentPoint()
+D3DVECTOR SegmentDist(const D3DVECTOR &p1, const D3DVECTOR &p2, float dist);
+
+//>>> 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(D3DVECTOR center, float angleH, float angleV, D3DVECTOR &p);
+
+//>>> geometry.h RotatePoint2()
+void RotatePoint2(D3DVECTOR center, float angleH, float angleV, D3DVECTOR &p);
+
+//>>> geometry.h RotateView()
+D3DVECTOR RotateView(D3DVECTOR center, float angleH, float angleV, float dist);
+
+//>>> geometry.h LookatPoint()
+D3DVECTOR LookatPoint( D3DVECTOR eye, float angleH, float angleV, float length );
+
+//>>> 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()
+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()
+D3DVECTOR Transform(const D3DMATRIX &m, D3DVECTOR p);
+
+//>>> geometry.h Projection()
+D3DVECTOR Projection(const D3DVECTOR &a, const D3DVECTOR &b, const D3DVECTOR &p);
+
+//>>> 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()
+void MatRotateXZY(D3DMATRIX &mat, D3DVECTOR angle);
+
+//>>> geometry.h LoadRotationZXYMatrix()
+void MatRotateZXY(D3DMATRIX &mat, D3DVECTOR angle);
+
+
+
// UNUSED
float MidPoint(FPOINT a, FPOINT b, float px);
diff --git a/src/math/old/math3d.h b/src/math/old/math3d.h
index 0a3ddc1..5ef6f43 100644
--- a/src/math/old/math3d.h
+++ b/src/math/old/math3d.h
@@ -24,77 +24,12 @@
#include "common/struct.h"
-//>>> geometry.h SegmentPoint()
-D3DVECTOR SegmentDist(const D3DVECTOR &p1, const D3DVECTOR &p2, float dist);
-
-//>>> 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(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 );
-
-//>>> 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 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);
-
-
// TODO
D3DCOLOR RetColor(float intensity);