# Changeset 240:4a1d2e642552 in lemon-0.x

Ignore:
Timestamp:
03/23/04 18:28:47 (20 years ago)
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@338
Message:

Elkészült a boundingbox osztály (boundingbox.h) és hozzá a tesztprogi.

Location:
src/work/athos/xy
Files:
2 added
2 edited

Unmodified
Added
Removed
• ## src/work/athos/xy/xy.cc

 r207 { cout << "Még egy skalárt is kérek (szépen)!" << endl; cout << "Kérek szépen egy egész számot!" << endl; int s; cin >> s;
• ## src/work/athos/xy/xy.h

 r237 template class xy { T _x,_y; public: T x,y; ///Default constructor: both coordinates become 0 xy() : _x(0), _y(0 ){ /*_x=_y=0;*/ } xy() : x(0), y(0) {} ///Constructing from coordinates xy(T a, T b) : _x(a), _x(b) { /*_x=a; _y=b;*/ } ///Constructing the instance from coordinates xy(T a, T b) : x(a), y(a) { } ///Gives back the x coordinate T x(){ return _x; }; ///Gives back the y coordinate T y(){ return _y; }; ///Gives back the square of the norm of the vector T normSquare(){ return _x*_x+_y*_y; return x*x+y*y; }; ///Increments the left hand side by u xy& operator +=(const xy& u){ _x += u._x; _y += u._y; x += u.x; y += u.y; return *this; }; ///Decrements the left hand side by u xy& operator -=(const xy& u){ _x -= u._x; _y -= u._y; x -= u.x; y -= u.y; return *this; }; ///Multiplying the left hand side with a scalar xy& operator *=(const T &u){ _x *= u; _y *= u; x *= u; y *= u; return *this; }; ///Dividing the left hand side by a scalar xy& operator /=(const T &u){ _x /= u; _y /= u; x /= u; y /= u; return *this; }; ///Returns the scalar product of two vectors T operator *(const xy& u){ return _x*u._x+_y*u._y; return x*u.x+y*u.y; }; ///Testing equality bool operator==(const xy &u){ return (_x==u._x) && (_y==u._y); return (x==u.x) && (y==u.y); }; ///Testing inequality bool operator!=(xy u){ return  (_x!=u._x) || (_y!=u._y); return  (x!=u.x) || (y!=u.y); }; std::istream& operator>>(std::istream &is, xy &z) { ///This is not the best solution here: I didn't know how to solve this with friend functions T a,b; is >> a >> b; xy buf(a,b); z=buf; is >> z.x >> z.y; return is; } std::ostream& operator<<(std::ostream &os, xy z) { os << "(" << z.x() << ", " << z.y() << ")"; os << "(" << z.x << ", " << z.y << ")"; return os; }
Note: See TracChangeset for help on using the changeset viewer.