Making changes to Vector3 related stuff.

This commit is contained in:
Brian 2014-02-20 21:15:54 -07:00
parent 4fd8dfb9f1
commit ce04edb8cb
4 changed files with 65 additions and 7 deletions

View file

@ -12,4 +12,24 @@
typedef float Scalar;
// May not need this, so may be removed.
struct CoordinateSystem
{
struct Types
{
enum Enum
{
RightHandedZUp, // x-right, y-forward, z-up
RightHandedYUp, // x-right, y-up, z-backwards
LeftHandedZUp, // x-left y-forward, z-up
LeftHandedYUp // x-right, y-up, z-backwards
};
};
// set this to whichever you like
static const Types::Enum Type = Types::RightHandedZUp;
// If I want to provide helpers for up/down/left/right/forward/backwards vectors, then you'll need to know the coordinate system type^
};
#endif

View file

@ -48,7 +48,8 @@
bool IsZero( void ) const;
static TVector3 Zero( void );
// Predefined helper vectors
static TVector3 Zero;
};
typedef TVector3< Scalar > Vec3f;
@ -176,4 +177,7 @@
return x == 0 && y == 0 && z == 0;
}
template< typename BaseType >
TVector3< BaseType > TVector3< BaseType >::Zero = TVector3< BaseType >(0.f, 0.f, 0.f);
#endif

View file

@ -5,6 +5,8 @@
using namespace igloo;
#include "math/Vector3.h"
// Testing headers:
#include "tests/TestsVector3.h"

View file

@ -7,9 +7,7 @@
{
Then( it_should_be_correct )
{
value1.x = 1.f;
value1.y = 1.f;
value1.z = 1.f;
value1 = Vec3f( 1.f, 1.f, 1.f );
value1 *= 2.f;
@ -23,9 +21,7 @@
{
Then( it_should_be_correct )
{
value1.x = 2.f;
value1.y = 2.f;
value1.z = 2.f;
value1 = Vec3f( 2.f, 2.f, 2.f );
value1 /= 2.f;
@ -35,4 +31,40 @@
Vec3f value1;
};
When( vector3_scalar_multiply_assignment )
{
Then( it_should_be_correct )
{
value1 = Vec3f( 1.f, 1.f, 1.f ) * 2.f;
Assert::That( value1, Equals( Vec3f( 2.f, 2.f, 2.f ) ) );
}
Vec3f value1;
};
When( vector3_scalar_divide_assignment )
{
Then( it_should_be_correct )
{
value1 = Vec3f( 2.f, 2.f, 2.f ) / 2.f;
Assert::That( value1, Equals( Vec3f( 1.f, 1.f, 1.f ) ) );
}
Vec3f value1;
};
When( vector3_set_to_zero )
{
Then( it_should_be_correct )
{
value1 = Vec3f::Zero;
Assert::That( value1, Equals( Vec3f( 0.f, 0.f, 0.f ) ) );
}
Vec3f value1;
};
#endif //__TESTSVECTOR3_H__