Added many comments, and changed function names for wrapper functions.

This commit is contained in:
rude
2009-08-09 21:08:55 +02:00
parent f2adfd53f2
commit ba1a75e547
103 changed files with 2608 additions and 2391 deletions
+75 -21
View File
@@ -21,30 +21,30 @@
#ifndef LOVE_MATRIX_H
#define LOVE_MATRIX_H
// STD
#include <cmath>
// LOVE
#include "math.h"
namespace love
{
// Forward declarations.
class Vector;
/**
* This class is the basis for all transformations in LOVE. Althought not
* really needed for 2D, it contains 4x4 elements to be compatible with
* OpenGL without conversions.
**/
class Matrix
{
friend class Vector;
private:
/**
* | e0 e4 e8 e12 |
* | e1 e5 e9 e13 |
* | e2 e6 e10 e14 |
* | e3 e7 e11 e15 |
**/
float e[16];
public:
// | e0 e4 e8 e12 |
// | e1 e5 e9 e13 |
// | e2 e6 e10 e14 |
// | e3 e7 e11 e15 |
float e[16];
/**
* Creates a new identity matrix.
**/
@@ -55,19 +55,53 @@ namespace love
**/
~Matrix();
/**
* Multiplies this Matrix with another Matrix, changing neither.
* @param m The Matrix to multiply with this Matrix.
* @return The combined matrix.
**/
Matrix operator * (const Matrix & m) const;
void operator *= (const Matrix & m) const;
/**
* Multiplies a Matrix into this Matrix.
* @param m The Matrix to combine into this Matrix.
**/
void operator *= (const Matrix & m);
/**
* Gets a pointer to the 16 array elements.
* @return The array elements.
**/
const float * getElements() const;
/**
* Resets this Matrix to the identity matrix.
**/
void setIdentity();
/**
* Resets this Matrix to a translation.
* @param x Translation along x-axis.
* @param y Translation along y-axis.
**/
void setTranslation(float x, float y);
void setRotation(float rad);
/**
* Resets this Matrix to a rotaion.
* @param r The angle in radians.
**/
void setRotation(float r);
/**
* Resets this Matrix to a scale transformation.
* @param sx Scale factor along the x-axis.
* @param sy Scale factor along the y-axis.
**/
void setScale(float sx, float sy);
/**
* Creates a transformation with a certain position, orientation, scale
* and offset.
* and offset. Perfect for Drawables -- what a coincidence!
*
* @param x The translation along the x-axis.
* @param y The translation along the y-axis.
@@ -79,17 +113,37 @@ namespace love
**/
void setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy);
/**
* Multiplies this Matrix with a translation.
* @param x Translation along x-axis.
* @param y Translation along y-axis.
**/
void translate(float x, float y);
void rotate(float rad);
/**
* Multiplies this Matrix with a rotation.
* @param r Angle in radians.
**/
void rotate(float r);
/**
* Multiplies this Matrix with a scale transformation.
* @param sx Scale factor along the x-axis.
* @param sy Scale factor along the y-axis.
**/
void scale(float sx, float sy);
/**
* Transforms an array of vertices.
* @stride Stride in bytes.
* Transforms an array of vertices by this Matrix. The sources and
* destination arrays may be the same.
*
* @param dst Storage for the transformed vertices.
* @param src The source vertices.
* @param size The number of vertices.
**/
void transform(vertex * dst, const vertex * src, int size);
};
}; // Matrix
} //love