SDL SPOOKY PLATFORMER ENGINE  0.2.0
An implementation of a platformer using sdl, implemented using an entity component system and efficient collision management.
Classes | Functions
TinyMath.hpp File Reference
#include <cmath>
#include <iostream>

Go to the source code of this file.

Classes

struct  Matrix3D
 
struct  Vector3D
 

Functions

static Vector3D abs (const Vector3D &other)
 
bool operator< (const Vector3D &a, float scalar)
 
float Dot (const Vector3D &a, const Vector3D &b)
 
Vector3D operator* (const Vector3D &v, float s)
 
Vector3D operator* (const Vector3D &v, const Vector3D &s)
 
Vector3D operator/ (const Vector3D &v, float s)
 
Vector3D operator- (const Vector3D &v)
 
float Magnitude (const Vector3D &v)
 
Vector3D operator+ (const Vector3D &a, const Vector3D &b)
 
Vector3D operator- (const Vector3D &a, const Vector3D &b)
 
Vector3D Project (const Vector3D &a, const Vector3D &b)
 
Vector3D Normalize (const Vector3D &v)
 
Vector3D CrossProduct (const Vector3D &a, const Vector3D &b)
 
Matrix3D operator* (const Matrix3D &A, const Matrix3D &B)
 
Vector3D operator* (const Matrix3D &M, const Vector3D &v)
 
std::ostream & operator<< (std::ostream &os, const Vector3D &v)
 
std::ostream & operator<< (std::ostream &os, const Matrix3D &m)
 

Function Documentation

static Vector3D abs ( const Vector3D other)
static

Returns the absolute value of the given vector.

Parameters
otherthe given
Vector3D CrossProduct ( const Vector3D a,
const Vector3D b 
)
inline

a x b Produces a new vector perpendicular to a and b. (So long as a and b are not parallel which returns zero vector)

Parameters
avector1
bvector2
float Dot ( const Vector3D a,
const Vector3D b 
)
inline

Compute the dot product of two Vector3D

Parameters
avector1
bvector2
float Magnitude ( const Vector3D v)
inline

Return the magnitude of a vector

Parameters
vthe vector
Vector3D Normalize ( const Vector3D v)
inline

Set a vectors magnitude to 1 Note: This is NOT generating a normal vector

Parameters
vvector1
Matrix3D operator* ( const Matrix3D A,
const Matrix3D B 
)
inline

Matrix Multiplication

Parameters
Amatrix1
Bmatrix2
Vector3D operator* ( const Matrix3D M,
const Vector3D v 
)
inline

Matrix multiply by a vector

Parameters
Mmatrix1
vvector1
Vector3D operator* ( const Vector3D v,
const Vector3D s 
)
inline

Multiplication of a vector by a vector storing scalar values. Allows for element-wise multiplication.

Parameters
vvector1
sthe scalar vector
Vector3D operator* ( const Vector3D v,
float  s 
)
inline

Multiplication of a vector by a scalar values

Parameters
vthe vector
sthe scalar
Vector3D operator+ ( const Vector3D a,
const Vector3D b 
)
inline

Add two vectors together

Parameters
avector1
bvector2
Vector3D operator- ( const Vector3D a,
const Vector3D b 
)
inline

Subtract two vectors, component-wise.

Parameters
avector1
bvector2

a - b

Vector3D operator- ( const Vector3D v)
inline

Negation of a vector Use Case: Sometimes it is handy to apply a force in an opposite direction

Parameters
vthe vector to negate
Vector3D operator/ ( const Vector3D v,
float  s 
)
inline

Division of a vector by a scalar value.

Parameters
vthe vector
sscalar value
bool operator< ( const Vector3D a,
float  scalar 
)
inline

Checks if a given vectors components are all less than a scalar value. A more useful way to use this function may be to take the absolute value of the vector first.

Parameters
athe given
scalarthe comparable scalar
std::ostream& operator<< ( std::ostream &  os,
const Matrix3D m 
)
inline

Print a matrix to the given stream.

Parameters
osthe stream
mthe matrix
std::ostream& operator<< ( std::ostream &  os,
const Vector3D v 
)
inline

Print a vector to the given stream.

Parameters
osthe stream
vthe vector
Vector3D Project ( const Vector3D a,
const Vector3D b 
)
inline

Vector Projection projects b onto a: proj_a_(b)

Parameters
avector1
bvector2