~swag/armagetronad/0.2.9-sty+ct+ap-fork

« back to all changes in this revision

Viewing changes to src/engine/eRectangle.h

  • Committer: luke-jr
  • Date: 2006-05-29 01:55:42 UTC
  • Revision ID: svn-v3-list-QlpoOTFBWSZTWZvbKhsAAAdRgAAQABK6798QIABURMgAAaeoNT1TxT1DQbKaeobXKiyAmlWT7Y5MkdJOtXDtB7w7DOGFBHiOBxaUIu7HQyyQSvxdyRThQkJvbKhs:7d95bf1e-0414-0410-9756-b78462a59f44:armagetronad%2Fbranches%2F0.2.8%2Farmagetronad:4612
Unify tags/branches of modules released together

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
*************************************************************************
 
4
 
 
5
ArmageTron -- Just another Tron Lightcycle Game in 3D.
 
6
Copyright (C) 2005  by Manuel Moos (z-man@users.sf.net)
 
7
and the AA DevTeam (see the file AUTHORS(.txt) in the main source directory)
 
8
 
 
9
**************************************************************************
 
10
 
 
11
This program is free software; you can redistribute it and/or
 
12
modify it under the terms of the GNU General Public License
 
13
as published by the Free Software Foundation; either version 2
 
14
of the License, or (at your option) any later version.
 
15
 
 
16
This program is distributed in the hope that it will be useful,
 
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
GNU General Public License for more details.
 
20
 
 
21
You should have received a copy of the GNU General Public License
 
22
along with this program; if not, write to the Free Software
 
23
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
24
  
 
25
***************************************************************************
 
26
 
 
27
*/
 
28
 
 
29
#ifndef ArmageTron_eRECTANGLE_H
 
30
#define ArmageTron_eRECTANGLE_H
 
31
 
 
32
#include "eCoord.h"
 
33
 
 
34
//! the rectangle containing the arena
 
35
class eRectangle
 
36
{
 
37
public:
 
38
    eRectangle();                                           //!< constructor to empty rectangle
 
39
    eRectangle( eCoord const & low, eCoord const & high );  //!< constructor
 
40
 
 
41
    void Clear();                                  //!< resets to empty state
 
42
    eRectangle & Include( eCoord const & point );  //!< include the given point into the rectangle
 
43
    bool Contains( eCoord const & point ) const;   //!< checks whether the given point lies inside the rectangle
 
44
    REAL Clamp( eCoord & point ) const;            //!< clamps the point to lie inside the rectangle
 
45
    REAL Clip( eCoord const & start, eCoord & stop ) const; //!< clips stop to lie inside the rectangle without changing the direction start->stop
 
46
    eCoord GetPoint( eCoord const & in ) const;    //!< returns a point in the interior
 
47
 
 
48
private:
 
49
    eCoord low_;  //!< low corner
 
50
    eCoord high_; //!< high corner
 
51
 
 
52
    // accessors
 
53
public:
 
54
    inline eCoord const & GetLow( void ) const;                 //!< Gets low corner
 
55
    inline eRectangle const & GetLow( eCoord & low ) const;         //!< Gets low corner
 
56
    inline eCoord const & GetHigh( void ) const;                    //!< Gets high corner
 
57
    inline eRectangle const & GetHigh( eCoord & high ) const;   //!< Gets high corner
 
58
protected:
 
59
private:
 
60
    inline eRectangle & SetLow( eCoord const & low );           //!< Sets low corner
 
61
    inline eRectangle & SetHigh( eCoord const & high );         //!< Sets high corner
 
62
};
 
63
 
 
64
// ****************************************************************************
 
65
// *
 
66
// *    GetLow
 
67
// *
 
68
// ****************************************************************************
 
69
//!
 
70
//!             @return         low corner
 
71
//!
 
72
// ****************************************************************************
 
73
 
 
74
eCoord const & eRectangle::GetLow( void ) const
 
75
{
 
76
    return this->low_;
 
77
}
 
78
 
 
79
// ****************************************************************************
 
80
// *
 
81
// *    GetLow
 
82
// *
 
83
// ****************************************************************************
 
84
//!
 
85
//!             @param  low     low corner to fill
 
86
//!             @return         A reference to this to allow chaining
 
87
//!
 
88
// ****************************************************************************
 
89
 
 
90
eRectangle const & eRectangle::GetLow( eCoord & low ) const
 
91
{
 
92
    low = this->low_;
 
93
    return *this;
 
94
}
 
95
 
 
96
// ****************************************************************************
 
97
// *
 
98
// *    SetLow
 
99
// *
 
100
// ****************************************************************************
 
101
//!
 
102
//!             @param  low     low corner to set
 
103
//!             @return         A reference to this to allow chaining
 
104
//!
 
105
// ****************************************************************************
 
106
 
 
107
eRectangle & eRectangle::SetLow( eCoord const & low )
 
108
{
 
109
    this->low_ = low;
 
110
    return *this;
 
111
}
 
112
 
 
113
// ****************************************************************************
 
114
// *
 
115
// *    GetHigh
 
116
// *
 
117
// ****************************************************************************
 
118
//!
 
119
//!             @return         high corner
 
120
//!
 
121
// ****************************************************************************
 
122
 
 
123
eCoord const & eRectangle::GetHigh( void ) const
 
124
{
 
125
    return this->high_;
 
126
}
 
127
 
 
128
// ****************************************************************************
 
129
// *
 
130
// *    GetHigh
 
131
// *
 
132
// ****************************************************************************
 
133
//!
 
134
//!             @param  high    high corner to fill
 
135
//!             @return         A reference to this to allow chaining
 
136
//!
 
137
// ****************************************************************************
 
138
 
 
139
eRectangle const & eRectangle::GetHigh( eCoord & high ) const
 
140
{
 
141
    high = this->high_;
 
142
    return *this;
 
143
}
 
144
 
 
145
// ****************************************************************************
 
146
// *
 
147
// *    SetHigh
 
148
// *
 
149
// ****************************************************************************
 
150
//!
 
151
//!             @param  high    high corner to set
 
152
//!             @return         A reference to this to allow chaining
 
153
//!
 
154
// ****************************************************************************
 
155
 
 
156
eRectangle & eRectangle::SetHigh( eCoord const & high )
 
157
{
 
158
    this->high_ = high;
 
159
    return *this;
 
160
}
 
161
 
 
162
#endif