2
* Copyright (C) 2002-2004 by the Wide Lands Development Team
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31
Point(int px, int py) : x(px), y(py) { }
34
inline bool operator==(Point a, Point b) { return (a.x == b.x) && (a.y == b.y); }
35
inline bool operator!=(Point a, Point b) { return (a.x != b.x) || (a.y != b.y); }
36
// TODO adding points doesn't make sense
37
inline Point operator+(Point a, Point b) { return Point(a.x + b.x, a.y + b.y); }
38
inline Point operator-(Point a, Point b) { return Point(a.x - b.x, a.y - b.y); }
40
struct Rect : public Point {
45
Rect(int px, int py, int pw, int ph) : Point(px, py), w(pw), h(ph) { }
48
/** class Point_with_bright
49
* this class is like a point, but with additional bright factor
50
* bright is an int to make it possible to directly save shifted values (8.8 fixed or so)
52
struct Point_with_bright : public Point {
54
Point_with_bright() : Point(0,0) { b=0; }
55
Point_with_bright(int px, int py, int pb) : Point(px, py) { b=pb; }
60
* This replaces Point_with_bright for use with the new texture mapping renderer.
62
* This struct is like a point, but with an additional bright factor and texture coordinates.
64
struct Vertex:public Point {
66
Vertex (): Point (0,0) { b=tx=ty=0; }
67
Vertex (int vx,int vy,int vb,int vtx,int vty): Point (vx,vy)
68
{ b=vb; tx=vtx; ty=vty; }
72
// tried to be faster with fixed point arithmetics
73
// it was, but i'll try to find other opts first
84
Vector(float px, float py, float pz)
86
x = px; y = py; z = pz;
90
float f = (float)sqrt(x*x + y*y + z*z);
100
inline Vector operator + (const Vector& a, const Vector& b)
102
return Vector(a.x + b.x, a.y + b.y, a.z + b.z);
106
inline float operator * (const Vector& a, const Vector& b)
108
return a.x * b.x + a.y * b.y + a.z * b.z;
112
// Structure used to store map coordinates
118
inline Coords(int nx, int ny) : x(nx), y(ny) { }
121
inline bool operator==(const Coords& c1, const Coords& c2) { return (c1.x == c2.x) && (c1.y == c2.y); }
122
inline bool operator!=(const Coords& c1, const Coords& c2) { return !(c1 == c2); }
126
struct FCoords : public Coords {
130
inline FCoords(Coords nc, Field *nf) : Coords(nc), field(nf) { }
131
inline FCoords(int nx, int ny, Field *nf) : Coords(nx, ny), field(nf) { }
134
#endif /* GEOMETRY_H */