E:/Eigene Dateien/Eigene Projekte/c0re/Vector3d.cpp

Go to the documentation of this file.
00001 /*
00002         This file is part of c0re.
00003 
00004         c0re is a multiplayer RTS on a hexagonal map with an evolving unit concept.
00005     Copyright (C) 2007 Stephan Hofmann
00006 
00007     c0re is free software: you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation, either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #include "Vector3d.h"
00022 
00023 #include <math.h>
00024 
00025 Vector3d::Vector3d()
00026 {
00027         x = 0.0;
00028         y = 0.0;
00029         z = 0.0;
00030 }
00031 
00032 Vector3d::Vector3d( double p_x, double p_y, double p_z )
00033 {
00034         x = p_x;
00035         y = p_y;
00036         z = p_z;
00037 }
00038 
00039 double Vector3d::length()
00040 {
00041         double ret = sqrt(x*x + y*y + z*z);
00042         return ret;
00043 }
00044 
00045 Vector3d Vector3d::operator+( Vector3d summand )
00046 {
00047         Vector3d ret;
00048         ret.x = x + summand.x;
00049         ret.y = y + summand.y;
00050         ret.z = z + summand.z;
00051         return ret;
00052 }
00053 
00054 Vector3d Vector3d::operator-( Vector3d subtrahend )
00055 {
00056         Vector3d ret;
00057         ret.x = x - subtrahend.x;
00058         ret.y = y - subtrahend.y;
00059         ret.z = z - subtrahend.z;
00060         return ret;
00061 }
00062 
00063 Vector3d Vector3d::operator*( double factor )
00064 {
00065         Vector3d ret;
00066         ret.x = x * factor;
00067         ret.y = y * factor;
00068         ret.z = z * factor;
00069         return ret;
00070 }
00071 
00072 Vector3d Vector3d::operator/( double divident )
00073 {
00074         Vector3d ret;
00075         ret.x = x / divident;
00076         ret.y = y / divident;
00077         ret.z = z / divident;
00078         return ret;
00079 }
00080 
00081 Vector3d Vector3d::operator+=( Vector3d summand )
00082 {
00083         return  *this = *this + summand;
00084 }
00085 
00086 Vector3d Vector3d::operator-=( Vector3d subtrahend )
00087 {
00088         return  *this = *this - subtrahend;
00089 }
00090 
00091 Vector3d Vector3d::operator*=( double factor )
00092 {
00093         return  *this = *this * factor;
00094 }
00095 
00096 Vector3d Vector3d::operator/=( double divident )
00097 {
00098         return  *this = *this / divident;
00099 }
00100 
00101 
00102 Vector3d::~Vector3d()
00103 {
00104 }

Generated on Tue Jul 17 22:02:22 2007 for C0re by  doxygen 1.5.2