25 #ifndef __I6ENGINE_MATH_I6EVECTOR2_H__
26 #define __I6ENGINE_MATH_I6EVECTOR2_H__
48 static const double EPSILON;
62 i6eVector2(
const T x,
const T y) : _x(x), _y(y), _valid(true) {
70 explicit i6eVector2(
const std::string & s) : _x(), _y(), _valid(true) {
71 std::stringstream stream(s);
81 i6eVector2(
const std::map<std::string, std::string> & params,
const std::string & prefix) : _x(), _y(), _valid(true) {
82 std::stringstream stream(params.find(prefix)->second);
146 return a._x * b._x + a._y * b._y;
178 return !(*
this == b);
194 void insertInMap(
const std::string & prefix, std::map<std::string, std::string> & map)
const {
195 std::stringstream ss;
196 ss << _x <<
" " << _y;
197 map[prefix] = ss.str();
225 return T(std::sqrt(_x * _x + _y * _y));
236 s << _x <<
" " << _y;
243 template<
class Archive>
255 const double i6eVector2<T>::EPSILON = 1e-15;
258 const i6eVector2<T> i6eVector2<T>::ZERO = i6eVector2<T>(T(), T());
267 return std::fabs(first.
getX() - second.
getX()) < FLT_EPSILON && std::fabs(first.
getY() - second.
getY()) < FLT_EPSILON;
i6eVector2 operator-(const i6eVector2 &b) const
Operator '-' for Vectors.
ISIXE_MATH_API std::ostream & operator<<(std::ostream &stream, const Vec2 &v)
stream operator for the i6eVector2
i6e::math::i6eVector2< uint32_t > Vec2ui
bool operator!=(const i6eVector2 &b) const
Operator '!=' for Vector.
std::enable_if< std::is_integral< T >::value, bool >::type operator==(const i6eVector2< T > &first, const i6eVector2< T > &second)
i6e::math::i6eVector2< double > Vec2
i6eVector2 operator/(const T b) const
Operator '/' for Vectors with a scalar.
i6eVector2 operator*=(T d)
operator '*=' for scalars
Implements 2-dimensional vectors.
i6eVector2 operator*(const T b) const
operator '*' for scalars
static const i6eVector2 ZERO
#define ISIXE_THROW_API(module, message)
i6eVector2 normalize() const
returns the normalized Vector
i6e::math::i6eVector2< int32_t > Vec2i
i6eVector2 operator+=(const i6eVector2 &b)
Operator '+=' for Vectors.
i6eVector2(const T x, const T y)
Creates a new vector with all values set to the given values.
bool isValid() const
determins whether the vector contains valid data This has to be set by the user. Operations resulting...
T getX() const
getters for the values of the Vector
static T scalProd(const i6eVector2 &a, const i6eVector2 &b)
operator '*' for vectors
i6eVector2 operator-=(const i6eVector2 &b)
Operator '-=' for Vectors.
void setX(const T x)
setters for the values of the Vector
i6e::math::i6eVector2< float > Vec2f
void mulComponents(const i6eVector2 &b)
muliplies two Vectors per component
i6eVector2(const std::string &s)
std::string toString() const
converts Vector to std::string
i6eVector2(const std::map< std::string, std::string > ¶ms, const std::string &prefix)
T length() const
length of the Vector
void insertInMap(const std::string &prefix, std::map< std::string, std::string > &map) const
inserts this vector into an attributeMap using the given prefix
i6eVector2 operator+(const i6eVector2 &b) const
Operator '+' for Vectors.
void serialize(Archive &ar, const unsigned int)
serializer for the vector
i6eVector2()
Creates a new vector with all values set to 0.