Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Point.C

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Hari sundar   *
00003  *   hsundar@seas.upenn.edu   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #include "Point.h"
00021 
00022 Point::Point() : _x(0.0), _y(0.0), _z(0.0)
00023 {
00024 }
00025 
00026 Point::Point(double newx, double newy, double newz) : _x(newx), _y(newy), _z(newz)
00027 {
00028 }
00029 
00030 Point::Point(int newx, int newy, int newz) : _x(static_cast<double>(newx)),
00031         _y(static_cast<double>(newy)), _z(static_cast<double>(newz)) 
00032 { 
00033 }
00034 
00035 Point::Point(unsigned int newx, unsigned int newy, unsigned int newz) :
00036         _x(static_cast<double> (newx)), _y(static_cast<double> (newy)), _z(static_cast<double> (newz))
00037 { 
00038 }
00039 
00040 Point::Point(const Point &newposition) :
00041   _x(newposition._x), _y(newposition._y), _z(newposition._z)
00042 {
00043 }
00044 
00045 Point::~Point()
00046 {
00047 }
00048 
00049 Point Point::operator - () const {
00050         return Point(-_x, -_y, -_z);
00051 }
00052 
00053 void Point::operator *= (const int factor){
00054         _x*=factor;
00055         _y*=factor;
00056         _z*=factor;
00057 }
00058 
00059 void Point::operator *= (const double factor){
00060         _x*=factor;
00061         _y*=factor;
00062         _z*=factor;
00063 }
00064 
00065 void Point::operator /= (const int divisor){
00066         if (divisor == 0) return;
00067         _x /= static_cast<double>(divisor);
00068         _y /= static_cast<double>(divisor);
00069         _z /= static_cast<double>(divisor);
00070 }
00071 
00072 void Point::operator /= (const double divisor){
00073         if (divisor == 0) return;
00074         _x /= divisor;
00075         _y /= divisor;
00076         _z /= divisor;
00077 }
00078 
00079 void Point::operator += (const Point& other){
00080         _x += other._x;
00081         _y += other._y;
00082         _z += other._z;
00083 }
00084 
00085 Point Point::operator - (const Point &other){
00086         return Point(_x-other._x,_y-other._y, _z-other._z);
00087 }
00088 
00089 Point Point::operator - (const Point &other) const {
00090         return Point(_x-other._x,_y-other._y, _z-other._z);
00091 }
00092 
00093 Point Point::operator + (const Point &other){
00094         return Point(_x+other._x,_y+other._y, _z+other._z);
00095 }
00096 
00097 Point& Point::operator=(const Point &other){
00098         _x = other._x;
00099         _y = other._y;
00100         _z = other._z;
00101         return *this;
00102 }
00103 
00104 Point Point::operator /(const double divisor)
00105 {
00106         return Point(_x/divisor,_y/divisor, _z/divisor);
00107 }
00108 
00109 Point Point::operator *(const double factor)
00110 {
00111         return Point(_x*factor,_y*factor, _z*factor);
00112 }
00113 
00114 Point Point::TransMatMultiply(double *transMat, Point inPoint)
00115 {
00116         Point outPoint;
00117 
00118         outPoint._x = transMat[ 0]*inPoint._x +transMat[ 4]*inPoint._y +transMat[8]
00119                 *inPoint._z +transMat[12];
00120         outPoint._y = transMat[ 1]*inPoint._x +transMat[ 5]*inPoint._y +transMat[9]
00121                 *inPoint._z +transMat[13];
00122         outPoint._z = transMat[ 2]*inPoint._x +transMat[ 6]*inPoint._y
00123                 +transMat[10]*inPoint._z +transMat[14];
00124 
00125         return outPoint;
00126 }
00127 
00128 void Point::normalize() {
00129         double abs = sqrt(_x*_x + _y*_y + _z*_z);
00130         _x /= abs; _y /= abs; _z /= abs;
00131 }
00132 

Generated on Tue Mar 24 16:14:07 2009 for DENDRO by  doxygen 1.3.9.1