Biomechanical Joint Model
 Author: Anderson Maciel

comepoint3d.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2001 by Anderson Maciel                                 *
00003  *   andi.maciel@gmail.com                                                 *
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 
00031 
00032 
00033 #include <cmath>
00034 #include <algebra/comepoint3d.h>
00035 
00036 
00038 // Description: Class "COME_Point3D" constructor without parameter.
00039 // Parameters.: -
00040 // Return.....: -
00041 
00042 COME_Point3D::COME_Point3D () {
00043         x = 0.0;
00044         y = 0.0;
00045         z = 0.0;
00046 }
00047 
00048 
00050 // Description: Class "COME_Point3D" constructor with parameter.
00051 // Parameters.: double xi (initial x value), 
00052 //                              double yi (initial y value),
00053 //                              double zi (initial z value)
00054 // Return.....: -
00055 
00056 COME_Point3D::COME_Point3D (double xi, double yi, double zi) {
00057         x = xi;
00058         y = yi;
00059         z = zi;
00060 }
00061 
00062 
00064 // Description: Method "getX" returns the value of x attribute.
00065 // Parameters.: -
00066 // Return.....: x (value of x attribute)
00067 
00068 double COME_Point3D::getX() const {
00069         return x;
00070 }
00071 
00072 
00074 // Description: Method "getY" returns the value of y attribute.
00075 // Parameters.: -
00076 // Return.....: y (value of y attribute)
00077 
00078 double COME_Point3D::getY() const {
00079         return y;
00080 }
00081 
00082 
00084 // Description: Method "getZ" returns the value of z attribute.
00085 // Parameters.: -
00086 // Return.....: z (value of z attribute)
00087 
00088 double COME_Point3D::getZ() const {
00089         return z;
00090 }
00091 
00092 
00094 // Description: Method "getXY" set the value of x and y  
00095 //                              atributes to the parameters.
00096 // Parameters.: double xx (which receives the x value)
00097 //                              double yy (which receives the y value)  
00098 // Return.....: -
00099 
00100 void COME_Point3D::getXY(double &xx, double &yy) {
00101         xx = x;
00102         yy = y;
00103 }
00104 
00105 
00107 // Description: Method "getXZ" set the value of x and z  
00108 //                              atributes to the parameters.
00109 // Parameters.: double xx (which receives the x value)
00110 //                              double zz (which receives the z value)  
00111 // Return.....: -
00112 
00113 void COME_Point3D::getXZ(double &xx, double &zz) {
00114         xx = x;
00115         zz = z;
00116 }
00117 
00118 
00120 // Description: Method "getYZ" set the value of y and z  
00121 //                              atributes to the parameters.
00122 // Parameters.: double yy (which receives the y value)
00123 //                              double zz (which receives the z value)  
00124 // Return.....: -
00125 
00126 void COME_Point3D::getYZ(double &yy, double &zz) {
00127         yy = y;
00128         zz = z;
00129 }
00130 
00131 
00133 // Description: Method "getXYZ" set the value of x, y and z  
00134 //                              atributes to the parameters.
00135 // Parameters.: double xx (which receives the x value)
00136 //                              double yy (which receives the y value)
00137 //                              double zz (which receives the z value)  
00138 // Return.....: -
00139 
00140 void COME_Point3D::getXYZ(double &xx, double &yy, double &zz) {
00141         xx = x; 
00142         yy = y;
00143         zz = z;
00144 }
00145 
00146 
00148 // Description: Method "getPoint3D" get the point value.     
00149 // Parameters.: -       
00150 // Return.....: COME_Point3D (object)
00151 
00152 COME_Point3D COME_Point3D::getPoint3D(void) {
00153         return *this;
00154 }
00155 
00156 
00157 
00158 
00160 
00161 // Description: Method "getPointAsArray" get the point value.     
00162 
00163 // Parameters.: -       
00164 
00165 // Return.....: double * (pointer to the array)
00166 
00167 
00168 
00169 double* COME_Point3D::getPointAsArray( void ) const {
00170 
00171         double* array = new double[3]; 
00172 
00173         array[0] = x; 
00174 
00175         array[1] = y; 
00176 
00177         array[2] = z; 
00178 
00179         return array;
00180 
00181 }
00182 
00183 
00184 
00185 
00186 
00188 
00189 // Description: Method "getPoint" put the point value in an array.     
00190 
00191 // Parameters.: double v        
00192 
00193 // Return.....: -
00194 
00195 
00196 
00197 void COME_Point3D::getPoint(double v[]) {
00198 
00199         v[0] = x;
00200 
00201         v[1] = y;
00202 
00203         v[2] = z;
00204 
00205 }
00206 
00207 
00208 
00210 // Description: Method "setX" sends a new value to the x attribute.
00211 // Parameters.: double xx (contains a new value for x attribute)
00212 // Return.....: -               
00213 
00214 inline void COME_Point3D::setX(double xx) {
00215         x = xx;
00216 }
00217         
00218 
00220 // Description: Method "setY" sends a new value to the y attribute.
00221 // Parameters.: double yy (contains a new value for y attribute)
00222 // Return.....: -               
00223 
00224 inline void COME_Point3D::setY(double yy) {
00225         y = yy;
00226 }
00227 
00228 
00230 // Description: Method "setZ" sends a new value to the z attribute.
00231 // Parameters.: double z (contains a new value for z attribute)
00232 // Return.....: -               
00233 
00234 inline void COME_Point3D::setZ(double zz) {
00235         z = zz;
00236 }
00237 
00238 
00240 // Description: Method "setXY" sends a new value to the x and y 
00241 //                              attribute.
00242 // Parameters.: double xx (contains a new value for x attribute)
00243 //                              double yy (contains a new value for y attribute)
00244 // Return.....: -               
00245 
00246 void COME_Point3D::setXY(double xx, double yy) {
00247         x = xx;
00248         y = yy;
00249 }
00250 
00251 
00253 // Description: Method "setXZ" sends a new value to the x and z 
00254 //                              attribute.
00255 // Parameters.: double xx (contains a new value for x attribute)
00256 //                              double zz (contains a new value for z attribute)
00257 // Return.....: -               
00258 
00259 void COME_Point3D::setXZ(double xx, double zz) {
00260         x = xx;
00261         z = zz;
00262 }
00263 
00264 
00266 // Description: Method "setYZ" sends a new value to the y and z 
00267 //                              attribute.
00268 // Parameters.: double yy (contains a new value for y attribute)
00269 //                              double zz (contains a new value for z attribute)
00270 // Return.....: -               
00271 
00272 void COME_Point3D::setYZ(double yy, double zz) {
00273         y = yy;
00274         z = zz;
00275 }
00276 
00277 
00279 // Description: Method "setXYZ" sends a new value to the x, y and  
00280 //                              z attribute.
00281 // Parameters.: double xx (contains a new value for x attribute)
00282 //                              double yy (contains a new value for y attribute)
00283 //                              double zz (contains a new value for z attribute)
00284 // Return.....: -               
00285 
00286 void COME_Point3D::setXYZ(double xx, double yy, double zz) {
00287         x = xx;
00288         y = yy;
00289         z = zz;
00290 }
00291 
00292 
00294 // Description: Method that implements the overload of - operator
00295 // Parameters.: COME_Point3D p (object that has the value for the
00296 //                                               operation)
00297 // Parameters.: const COME_Point3D& p
00298 
00299 // Return.....: COME_Point3D (result from "-" operation)
00300 
00301 COME_Point3D COME_Point3D::operator- (const COME_Point3D& p) const{
00302  COME_Point3D vv(x-p.x, y-p.y, z-p.z);
00303  return ( vv ) ;
00304 } 
00305 
00306 
00308 // Description: Method that implements the overload of + operator
00309 // Parameters.: COME_Point3D p (object that has the value for the
00310 //                                               operation)
00311 // Parameters.: const COME_Point3D& p
00312 
00313 // Return.....: COME_Point3D (result from "+" operation)
00314 
00315 COME_Point3D COME_Point3D::operator+ (const COME_Point3D& p) {
00316  COME_Point3D vv(x+p.x, y+p.y, z+p.z);
00317  return ( vv ) ;
00318 } 
00319 
00320 
00322 // Description: Method that implements the overload of = operator
00323 // Parameters.: COME_Point3D p (object that has the new value for the
00324 //                                             attributes of the class)
00325 // Parameters.: const COME_Point3D& p
00326 
00327 // Return.....: COME_Point3D (current object)
00328 
00329 COME_Point3D COME_Point3D::operator= (COME_Point3D p) {
00330         x = p.x;
00331         y = p.y;
00332         z = p.z;
00333         return *this;
00334 }
00335 
00336 
00337 
00338 
00339 
00341 
00342 // Description: Method that implements the overload of -= operator
00343 
00344 // Parameters.: int num (number for subtraction)
00345 
00346 // Return.....: COME_Point3D (current object)
00347 
00348 
00349 
00350 COME_Point3D COME_Point3D::operator-= (int num) {
00351 
00352  x -= num;
00353 
00354  y -= num;
00355 
00356  z -= num;
00357 
00358  return *this;
00359 
00360 }
00361 
00362 
00363 
00365 
00366 // Description: Method that implements the overload of -= operator
00367 
00368 // Parameters.: int num (number for subtraction)
00369 
00370 // Return.....: COME_Point3D (current object)
00371 
00372 
00373 
00374 COME_Point3D COME_Point3D::operator-= (double num) {
00375 
00376  x -= num;
00377 
00378  y -= num;
00379 
00380  z -= num;
00381 
00382  return *this;
00383 
00384 }
00385 
00386 
00387 
00389 
00390 // Description: Method that implements the overload of -= operator
00391 
00392 // Parameters.: int num (number for subtraction)
00393 
00394 // Return.....: COME_Point3D (current object)
00395 
00396 
00397 
00398 COME_Point3D COME_Point3D::operator+= (double num) {
00399 
00400  x += num;
00401 
00402  y += num;
00403 
00404  z += num;
00405 
00406  return *this;
00407 
00408 }
00409 
00410 
00411 
00413 
00414 // Description: Method that implements the overload of -= operator
00415 
00416 // Parameters.: double num (number for multiplication)
00417 
00418 // Return.....: COME_Point3D (current object)
00419 
00420 
00421 
00422 COME_Point3D COME_Point3D::operator* (double num) {
00423 
00424  x *= num;
00425 
00426  y *= num;
00427 
00428  z *= num;
00429 
00430  return *this;
00431 
00432 }
00433 
00434 
00435 
00436 
00437 
00439 
00440 // Description: Method that implements the overload of != operator
00441 
00442 // Parameters.: const COME_Point3D& p (object to be compared)
00443 
00444 // Return.....: true or false
00445 
00446 
00447 
00448 bool COME_Point3D::operator!= (const COME_Point3D& p) {
00449 
00450         if ( (x!=p.x) || (y!=p.y) || (z!=p.z) )
00451 
00452                 return true;
00453 
00454         else
00455 
00456                 return false;
00457 
00458 }
00459 
00460 
00461 
00462 
00463 
00465 
00466 // Description: Method that implements the overload of == operator
00467 
00468 // Parameters.: const COME_Point3D p (object to be compared)
00469 
00470 // Return.....: true or false
00471 
00472 
00473 
00474 bool COME_Point3D::operator== (const COME_Point3D& p) {
00475 
00476         if ( (x==p.x) && (y==p.y) && (z==p.z) )
00477 
00478                 return true;
00479 
00480         else
00481 
00482                 return false;
00483 
00484 }
00485 
00486 
00487 
00488 
00489 
00491 
00492 // Description: Method that implements the overload of <= operator
00493 
00494 // Parameters.: const COME_Point3D p (object to be compared)
00495 
00496 // Return.....: true or false
00497 
00498 
00499 bool COME_Point3D::operator<= (const COME_Point3D& p) {
00500 
00501         if ( (x<=p.x) && (y<=p.y) && (z<=p.z) )
00502 
00503                 return true;
00504 
00505         else
00506 
00507                 return false;
00508 
00509 }
00510 
00511 
00512 
00513 
00514 
00516 
00517 // Description: Method that implements the overload of < operator
00518 
00519 // Parameters.: const COME_Point3D p (object to be compared)
00520 
00521 // Return.....: true or false
00522 
00523 
00524 
00525 bool COME_Point3D::operator< (const COME_Point3D& p) {
00526 
00527         if ( (x<p.x) && (y<p.y) && (z<p.z) )
00528 
00529                 return true;
00530 
00531         else
00532 
00533                 return false;
00534 
00535 }
00536 
00537 
00538 
00539 
00540 
00542 
00543 // Description: Method that implements the overload of >= operator
00544 
00545 // Parameters.: const COME_Point3D p (object to be compared)
00546 
00547 // Return.....: true or false
00548 
00549 
00550 
00551 bool COME_Point3D::operator>= (const COME_Point3D& p) {
00552 
00553         if ( (x>=p.x) && (y>=p.y) && (z>=p.z) )
00554 
00555                 return true;
00556 
00557         else
00558 
00559                 return false;
00560 
00561 }
00562 
00563 
00564 
00565 
00566 
00568 
00569 // Description: Method that implements the overload of > operator
00570 
00571 // Parameters.: const COME_Point3D p (object to be compared)
00572 
00573 // Return.....: true or false
00574 
00575 
00576 
00577 bool COME_Point3D::operator> (const COME_Point3D& p) {
00578 
00579         if ( (x>p.x) && (y>p.y) && (z>p.z) )
00580 
00581                 return true;
00582 
00583         else
00584 
00585                 return false;
00586 
00587 }
00588 
00589 
00590 
00591 
00593 // Description: Method that calculates the distance between two points
00594 // Parameters.: COME_Point3D p 
00595 // Return.....: double distance
00596 
00597 double COME_Point3D::vpDistance( const COME_Point3D& p1) {
00598         double d;
00599         d = (double)sqrt((x-p1.x)*(x-p1.x) +
00600                          (y-p1.y)*(y-p1.y) +
00601                          (z-p1.z)*(z-p1.z));
00602         return d;
00603 }
00604 
00605 
00606 

Generated on Thu Dec 1 10:13:35 2005 for COME - Biomechanical Joint Model by  doxygen 1.4.5