// Copyright (C) 2002-2007 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h #ifndef __IRR_POSITION_H_INCLUDED__ #define __IRR_POSITION_H_INCLUDED__ #include "irrTypes.h" #include "dimension2d.h" namespace irr { namespace core { //! Simple class for holding 2d coordinates. /** Not supposed for doing geometric calculations. use vector2d instead for things like that. */ template class position2d { public: position2d(T x, T y) : X(x), Y(y) {}; position2d() : X(0), Y(0) {}; position2d(const position2d& other) : X(other.X), Y(other.Y) {}; bool operator == (const position2d& other) const { return X == other.X && Y == other.Y; } bool operator != (const position2d& other) const { return X != other.X || Y != other.Y; } const position2d& operator+=(const position2d& other) { X += other.X; Y += other.Y; return *this; } const position2d& operator-=(const position2d& other) { X -= other.X; Y -= other.Y; return *this; } const position2d& operator+=(const dimension2d& other) { X += other.Width; Y += other.Height; return *this; } const position2d& operator-=(const dimension2d& other) { X -= other.Width; Y -= other.Height; return *this; } position2d operator-(const position2d& other) const { return position2d(X-other.X, Y-other.Y); } position2d operator+(const position2d& other) const { return position2d(X+other.X, Y+other.Y); } position2d operator*(const position2d& other) const { return position2d(X*other.X, Y*other.Y); } position2d operator*(const T& scalar) const { return position2d(X*scalar, Y*scalar); } position2d operator+(const dimension2d& other) const { return position2d(X+other.Width, Y+other.Height); } position2d operator-(const dimension2d& other) const { return position2d(X-other.Width, Y-other.Height); } const position2d& operator=(const position2d& other) { X = other.X; Y = other.Y; return *this; } T X, Y; }; //! Typedef for a f32 position. typedef position2d position2df; //! Typedef for an integer position. typedef position2d position2di; } // end namespace core } // end namespace irr #endif