/*************************************************************************** * Copyright (C) 2005-2019 by the FIFE team * * http://www.fifengine.net * * This file is part of FIFE. * * * * FIFE is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ %{ #include "util/structures/point.h" #include "util/structures/rect.h" %} namespace FIFE { template class PointType2D { public: T x; T y; explicit PointType2D(T _x = 0, T _y = 0); PointType2D(const PointType2D& rhs); PointType2D operator+(const PointType2D& p) const; PointType2D operator-(const PointType2D& p) const; PointType2D& operator+=(const PointType2D& p); PointType2D& operator-=(const PointType2D& p); PointType2D operator*(const T& i) const; PointType2D operator/(const T& i) const; bool operator==(const PointType2D& p) const; bool operator!=(const PointType2D& p) const; T length() const; void normalize(); void rotate(T angle); void rotate(const PointType2D& origin, T angle); void set(T _x, T _y); }; template std::ostream& operator<<(std::ostream& os, const PointType2D& p); typedef PointType2D Point; typedef PointType2D IntPoint; typedef PointType2D DoublePoint; typedef PointType2D IntPoint2D; typedef PointType2D DoublePoint2D; %template(Point) PointType2D; %template(DoublePoint) PointType2D; template class PointType3D { public: T x; T y; T z; explicit PointType3D(T _x = 0, T _y = 0, T _z = 0); PointType3D(const PointType3D& rhs); PointType3D operator+(const PointType3D& p) const; PointType3D operator-(const PointType3D& p) const; PointType3D& operator+=(const PointType3D& p); PointType3D& operator-=(const PointType3D& p); PointType3D operator*(const T& i) const; PointType3D operator/(const T& i) const; bool operator==(const PointType3D& p) const; bool operator!=(const PointType3D& p) const; T length() const; void normalize(); void set(T _x, T _y, T _z); }; template std::ostream& operator<<(std::ostream& os, const PointType3D& p); typedef PointType3D Point3D; typedef PointType3D IntPoint3D; typedef PointType3D DoublePoint3D; %template(Point3D) PointType3D; %template(DoublePoint3D) PointType3D; template class RectType { public: T x; T y; T w; T h; explicit RectType(T x = 0, T y = 0, T width = 0, T height = 0); T right() const; T bottom() const; bool operator==(const RectType& rect ) const; bool contains( const PointType2D& point ) const; bool intersects( const RectType& rect ) const; bool intersectInplace( const RectType& rect ); }; template std::ostream& operator<<(std::ostream&, const RectType&); typedef RectType Rect; typedef RectType FloatRect; typedef RectType DoubleRect; %template(Rect) RectType; %template(FloatRect) RectType; %template(DoubleRect) RectType; } namespace std { %template(FifePointVector) vector; }