Files
pvvmud/common/lib/srvcli/position.C
2025-03-05 08:37:43 +01:00

108 lines
3.2 KiB
C

/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "pvvmud.H"
#include "position.H"
CPosition::CPosition(){
position[0] = 0;
position[1] = 0;
position[2] = 0;
}
CPosition::CPosition(double * position){
this->position[0] = position[0];
this->position[1] = position[1];
this->position[2] = position[2];
}
CPosition::CPosition(double x, double y, double z){
position[0] = x;
position[1] = y;
position[2] = z;
}
CPosition::~CPosition(){
}
CPosition& CPosition::operator= (const CPosition& position) {
this->position[0] = position.position[0];
this->position[1] = position.position[1];
this->position[2] = position.position[2];
return *this;
}
CPosition& CPosition::operator+= (const CPosition& position) {
this->position[0] += position.position[0];
this->position[1] += position.position[1];
this->position[2] += position.position[2];
return *this;
}
int CPosition::operator< (const CPosition& position) const {
return ((this->position[0] < position.position[0])&&
(this->position[1] < position.position[1])&&
(this->position[2] < position.position[2]));
}
int CPosition::operator> (const CPosition& position) const {
return ((this->position[0] > position.position[0])&&
(this->position[1] > position.position[1])&&
(this->position[2] > position.position[2]));
}
int CPosition::operator<= (const CPosition& position) const {
return ((this->position[0] <= position.position[0])&&
(this->position[1] <= position.position[1])&&
(this->position[2] <= position.position[2]));
}
int CPosition::operator>= (const CPosition& position) const {
return ((this->position[0] >= position.position[0])&&
(this->position[1] >= position.position[1])&&
(this->position[2] >= position.position[2]));
}
double * CPosition::getVector(){
return position;
}
CPosition CPosition::operator- (const CPosition& position) const{
CPosition result;
result.position[0] = this->position[0] - position.position[0];
result.position[1] = this->position[1] - position.position[1];
result.position[2] = this->position[2] - position.position[2];
return result;
}
CPosition CPosition::operator- () const{
CPosition result;
result.position[0] = - position[0];
result.position[1] = - position[1];
result.position[2] = - position[2];
return result;
}
ostream& operator<<(ostream&s,const CPosition& p){
return s << "(" << p.getX() << "," << p.getY() << "," << p.getZ() << ")";
}