charles/src/basics/vector.hh

57 lines
1 KiB
C++
Raw Normal View History

2014-08-08 20:44:43 -07:00
/* vector.hh
* vim: set tw=80:
* Eryn Wells <eryn@erynwells.me>
*/
#ifndef __BASICS_VECTOR_HH__
#define __BASICS_VECTOR_HH__
#include "basics/matrix.hh"
#include "basics/types.hh"
namespace charles {
namespace basics {
template<UInt N>
2014-08-08 20:44:43 -07:00
struct Vector
: public Matrix<N,1>
{ };
2014-08-08 21:12:37 -07:00
struct Vector4
: public Vector<4>
{
Vector4();
Vector4(const Double& x, const Double& y, const Double& z);
2014-08-08 21:12:37 -07:00
Double& X();
Double& Y();
Double& Z();
/** Get the length-squared of this vector. */
Double Length2() const;
/** Get the length of this vector. */
Double Length() const;
/** Get the dot product of `this` and `rhs`. */
Double Dot(const Vector4& rhs) const;
/** Get the cross product of `this` and `rhs`. */
Vector4 Cross(const Vector4& rhs) const;
/** Normalize this vector. */
Vector4& Normalize();
2014-08-08 21:12:37 -07:00
};
2014-08-08 20:44:43 -07:00
/** Normalize the given vector and return a copy of it. */
Vector4& Normalized(const Vector4& v);
2014-08-08 20:44:43 -07:00
} /* namespace basics */
} /* namespace charles */
#endif /* __BASICS_VECTOR_HH__ */