Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

HxVec3Double.h

00001 /*
00002  *  Copyright (c) 1998, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *
00006  *  Author(s):
00007  *  Dennis Koelma (koelma@wins.uva.nl)
00008  *  Edo Poll (poll@wins.uva.nl)
00009  */
00010 
00011 #ifndef HxVec3Double_h
00012 #define HxVec3Double_h
00013 
00014 #include <cstdlib>
00015 #include "HxIoFwd.h"
00016 #include "HxMath.h"
00017 #include "HxString.h"
00018 
00019 #undef min
00020 #undef max
00021 
00022 class HxScalarInt;
00023 #include "HxScalarDouble.h"
00024 class HxVec2Int;
00025 class HxVec2Double;
00026 class HxVec3Int;
00027 class HxComplex;
00028 
00029 
00033 class L_HXBASIS HxVec3Double {
00034 public:
00035 
00037 
00039                             HxVec3Double();
00040 
00042                             HxVec3Double(double x, double y, double z);
00043                             
00045                             HxVec3Double(const HxVec3Double& v);
00047 
00048     void*                   operator new(size_t, void * = 0);
00049 
00051 
00054     int                     dim() const;
00055     
00057     double                  x() const;
00058     
00060     double                  y() const;
00061     
00063     double                  z() const;
00064 
00066     double                  getValue(int dimension) const; // dimension: 1, 2 or 3
00067     void                    setValue(int dimension, double value); // dimension: 1, 2 or 3
00069 
00071 /** \name Conversion*/
00073                             operator HxScalarInt() const;
00074 
00076                             operator HxScalarDouble() const;
00077 
00079                             operator HxVec2Int() const;
00080 
00082                             operator HxVec2Double() const;
00083 
00085                             operator HxVec3Int() const;
00086 
00088                             operator HxComplex() const;
00090 
00092 
00096     int                     operator==(const HxVec3Double& v) const;
00097 
00099     int                     operator!=(const HxVec3Double& v) const;
00100 
00102     int                     operator< (const HxVec3Double& v) const;
00103 
00105     int                     operator<=(const HxVec3Double& v) const;
00106 
00108     int                     operator> (const HxVec3Double& v) const;
00109 
00111     int                     operator>=(const HxVec3Double& v) const;
00112 
00117     static const HxVec3Double SMALL_VAL;
00118 
00123     static const HxVec3Double LARGE_VAL;
00125 
00127 
00131     HxVec3Double            operator-() const;
00132 
00134     HxVec3Double            complement() const;
00135 
00137     HxVec3Double            abs() const;
00138 
00140     HxVec3Double            ceil() const;
00141 
00143     HxVec3Double            floor() const;
00144 
00146     HxVec3Double            round() const;
00147 
00149     HxScalarDouble          sum() const;
00150     
00152     HxScalarDouble          product() const;
00153 
00155     HxScalarDouble          min() const;
00156 
00158     HxScalarDouble          max() const;
00159 
00161     HxScalarDouble          norm1() const;
00162 
00164     HxScalarDouble          norm2() const;
00165 
00167     HxScalarDouble          normInf() const;
00168 
00170     HxVec3Double            sqrt() const;
00171 
00173     HxVec3Double            sin() const;
00174 
00176     HxVec3Double            cos() const;
00177 
00179     HxVec3Double            tan() const;
00180 
00182     HxVec3Double            asin() const;
00183 
00185     HxVec3Double            acos() const;
00186 
00188     HxVec3Double            atan() const;
00189 
00191     HxScalarDouble          atan2() const;
00192 
00194     HxVec3Double            sinh() const;
00195 
00197     HxVec3Double            cosh() const;
00198 
00200     HxVec3Double            tanh() const;
00201 
00203     HxVec3Double            exp() const;
00204 
00206     HxVec3Double            log() const;
00207 
00209     HxVec3Double            log10() const;
00211 
00213 
00217     HxVec3Double&           operator+=(const HxVec3Double& v);
00218 
00220     HxVec3Double&           operator-=(const HxVec3Double& v);
00221 
00223     HxVec3Double&           operator*=(const HxVec3Double& v);
00224 
00226     HxVec3Double&           operator/=(const HxVec3Double& v);
00227 
00228 
00230     friend HxVec3Double     operator+(const HxVec3Double& v1,
00231                                       const HxVec3Double& v2);
00232 
00234     friend HxVec3Double     operator-(const HxVec3Double& v1,
00235                                       const HxVec3Double& v2);
00236 
00238     friend HxVec3Double     operator*(const HxVec3Double& v1,
00239                                       const HxVec3Double& v2);
00240 
00242     friend HxVec3Double     operator/(const HxVec3Double& v1,
00243                                       const HxVec3Double& v2);
00244 
00245 
00247     HxVec3Double            min(const HxVec3Double& v) const;
00248 
00250     HxVec3Double&           minAssign(const HxVec3Double& v);
00251 
00253     HxVec3Double            max(const HxVec3Double& v) const;
00254 
00256     HxVec3Double&           maxAssign(const HxVec3Double& v);
00257 
00259     HxVec3Double            inf(const HxVec3Double& v) const;
00260 
00262     HxVec3Double&           infAssign(const HxVec3Double& v);
00263 
00265     HxVec3Double            sup(const HxVec3Double& v) const;
00266 
00268     HxVec3Double&           supAssign(const HxVec3Double& v);
00269 
00271     HxVec3Double            pow(const HxVec3Double& v) const;
00272 
00274     HxVec3Double            mod(const HxVec3Double& v) const;
00275 
00277     HxVec3Double            and(const HxVec3Double& v) const;
00278 
00280     HxVec3Double            or(const HxVec3Double& v) const;
00281 
00283     HxVec3Double            xor(const HxVec3Double& v) const;
00284 
00286     HxVec3Double            leftShift(const HxVec3Double& v) const;
00287 
00289     HxVec3Double            rightShift(const HxVec3Double& v) const;
00290 
00292     HxScalarDouble          dot(const HxVec3Double& v) const;
00293 
00295     HxVec3Double            cross(const HxVec3Double& v) const;
00297 
00299 
00301     STD_OSTREAM&            put(STD_OSTREAM& os) const;
00302 
00304     HxString                toString() const;
00306 
00307 private:
00308     double                  _values[3];
00309 };
00310 
00311 typedef HxVec3Double (*HxUpoVec3Double)(const HxVec3Double& a);
00312 typedef HxVec3Double (*HxBpoVec3Double)(const HxVec3Double& a1, const HxVec3Double& a2);
00313 
00314 
00315 inline STD_OSTREAM&
00316 operator<<(STD_OSTREAM& os, const HxVec3Double v)
00317 {
00318     return v.put(os);
00319 }
00320 
00321 inline
00322 HxVec3Double::HxVec3Double() 
00323 { 
00324 }
00325 
00326 inline
00327 HxVec3Double::HxVec3Double(double x, double y, double z)
00328 {
00329     _values[0] = x;
00330     _values[1] = y;
00331     _values[2] = z;
00332 }
00333 
00334 inline
00335 HxVec3Double::HxVec3Double(const HxVec3Double& v)
00336 {
00337     _values[0] = v._values[0];
00338     _values[1] = v._values[1];
00339     _values[2] = v._values[2];
00340 }
00341 
00342 inline void*
00343 HxVec3Double::operator new(size_t size, void *m) 
00344 {
00345     return m ? m : new char[size];
00346 }
00347 
00348 inline int
00349 HxVec3Double::dim() const
00350 {
00351     return 3;
00352 }
00353 
00354 inline double
00355 HxVec3Double::x() const
00356 {
00357     return _values[0];
00358 }
00359 
00360 inline double
00361 HxVec3Double::y() const
00362 {
00363     return _values[1];
00364 }
00365 
00366 inline double
00367 HxVec3Double::z() const
00368 {
00369     return _values[2];
00370 }
00371 
00372 inline double
00373 HxVec3Double::getValue(int dimension) const
00374 {
00375     return _values[dimension - 1];
00376 }
00377 
00378 inline void
00379 HxVec3Double::setValue(int dimension, double value)
00380 {
00381     _values[dimension - 1] = value;
00382 }
00383 
00384 inline int
00385 HxVec3Double::operator==(const HxVec3Double& v) const
00386 {
00387     return (_values[0] == v._values[0]) && (_values[1] == v._values[1]) &&
00388            (_values[2] == v._values[2]);
00389 }
00390 
00391 inline int
00392 HxVec3Double::operator!=(const HxVec3Double& v) const
00393 {
00394     return (_values[0] != v._values[0]) || (_values[1] != v._values[1]) ||
00395            (_values[2] != v._values[2]);
00396 }
00397 
00398 inline int
00399 HxVec3Double::operator<(const HxVec3Double& v) const
00400 {
00401     return (fabs(_values[0]) + fabs(_values[1]) + fabs(_values[2])) < 
00402            (fabs(v._values[0]) + fabs(v._values[1]) + fabs(v._values[2]));
00403 }
00404 
00405 inline int
00406 HxVec3Double::operator<=(const HxVec3Double& v) const
00407 {
00408     return (fabs(_values[0]) + fabs(_values[1]) + fabs(_values[2])) <=
00409            (fabs(v._values[0]) + fabs(v._values[1]) + fabs(v._values[2]));
00410 }
00411 
00412 inline int
00413 HxVec3Double::operator>(const HxVec3Double& v) const
00414 {
00415     return (fabs(_values[0]) + fabs(_values[1]) + fabs(_values[2])) >
00416            (fabs(v._values[0]) + fabs(v._values[1]) + fabs(v._values[2]));
00417 }
00418 
00419 inline int
00420 HxVec3Double::operator>=(const HxVec3Double& v) const
00421 {
00422     return (fabs(_values[0]) + fabs(_values[1]) + fabs(_values[2])) >=
00423            (fabs(v._values[0]) + fabs(v._values[1]) + fabs(v._values[2]));
00424 }
00425 
00426 inline HxVec3Double
00427 HxVec3Double::operator-() const
00428 {
00429     return HxVec3Double(-_values[0], -_values[1], -_values[2]);
00430 }
00431 
00432 inline HxVec3Double
00433 HxVec3Double::complement() const
00434 {
00435     return HxVec3Double(-_values[0], -_values[1], -_values[2]);
00436 }
00437 
00438 inline HxVec3Double
00439 HxVec3Double::abs() const
00440 {
00441     return HxVec3Double(fabs(_values[0]), fabs(_values[1]), fabs(_values[2]));
00442 }
00443 
00444 inline HxVec3Double
00445 HxVec3Double::ceil() const
00446 {
00447     return HxVec3Double(::ceil(_values[0]),
00448                         ::ceil(_values[1]),
00449                         ::ceil(_values[2]));
00450 }
00451 
00452 inline HxVec3Double
00453 HxVec3Double::floor() const
00454 {
00455     return HxVec3Double(::floor(_values[0]),
00456                         ::floor(_values[1]),
00457                         ::floor(_values[2]));
00458 }
00459 
00460 inline HxVec3Double
00461 HxVec3Double::round() const
00462 {
00463     return HxVec3Double((int) (_values[0] + ((_values[0] >= 0) ? 0.5 : -0.5)),
00464                         (int) (_values[1] + ((_values[1] >= 0) ? 0.5 : -0.5)),
00465                         (int) (_values[2] + ((_values[2] >= 0) ? 0.5 : -0.5)));
00466 }
00467 
00468 inline HxScalarDouble
00469 HxVec3Double::sum() const
00470 {
00471     return _values[0] + _values[1] + _values[2];
00472 }
00473 
00474 inline HxScalarDouble
00475 HxVec3Double::product() const
00476 {
00477     return _values[0] * _values[1] * _values[2];
00478 }
00479 
00480 inline HxVec3Double
00481 HxVec3Double::sqrt() const
00482 {
00483     return HxVec3Double(::sqrt(_values[0]),
00484                         ::sqrt(_values[1]),
00485                         ::sqrt(_values[2]));
00486 }
00487 
00488 inline HxVec3Double
00489 HxVec3Double::sin() const
00490 {
00491     return HxVec3Double(::sin(_values[0]),
00492                         ::sin(_values[1]),
00493                         ::sin(_values[2]));
00494 }
00495 
00496 inline HxVec3Double
00497 HxVec3Double::cos() const
00498 {
00499     return HxVec3Double(::cos(_values[0]),
00500                         ::cos(_values[1]),
00501                         ::cos(_values[2]));
00502 }
00503 
00504 inline HxVec3Double
00505 HxVec3Double::tan() const
00506 {
00507     return HxVec3Double(::tan(_values[0]),
00508                         ::tan(_values[1]),
00509                         ::tan(_values[2]));
00510 }
00511 
00512 inline HxVec3Double
00513 HxVec3Double::asin() const
00514 {
00515     return HxVec3Double(::asin(_values[0]),
00516                         ::asin(_values[1]),
00517                         ::asin(_values[2]));
00518 }
00519 
00520 inline HxVec3Double
00521 HxVec3Double::acos() const
00522 {
00523     return HxVec3Double(::acos(_values[0]),
00524                         ::acos(_values[1]),
00525                         ::acos(_values[2]));
00526 }
00527 
00528 inline HxVec3Double
00529 HxVec3Double::atan() const
00530 {
00531     return HxVec3Double(::atan(_values[0]),
00532                         ::atan(_values[1]),
00533                         ::atan(_values[2]));
00534 }
00535 
00536 inline HxVec3Double
00537 HxVec3Double::sinh() const
00538 {
00539     return HxVec3Double(::sinh(_values[0]),
00540                         ::sinh(_values[1]),
00541                         ::sinh(_values[2]));
00542 }
00543 
00544 inline HxVec3Double
00545 HxVec3Double::cosh() const
00546 {
00547     return HxVec3Double(::cosh(_values[0]),
00548                         ::cosh(_values[1]),
00549                         ::cosh(_values[2]));
00550 }
00551 
00552 inline HxVec3Double
00553 HxVec3Double::tanh() const
00554 {
00555     return HxVec3Double(::tanh(_values[0]),
00556                         ::tanh(_values[1]),
00557                         ::tanh(_values[2]));
00558 }
00559 
00560 inline HxVec3Double
00561 HxVec3Double::exp() const
00562 {
00563     return HxVec3Double(::exp(_values[0]),
00564                         ::exp(_values[1]),
00565                         ::exp(_values[2]));
00566 }
00567 
00568 inline HxVec3Double
00569 HxVec3Double::log() const
00570 {
00571     return HxVec3Double(::log(_values[0]),
00572                         ::log(_values[1]),
00573                         ::log(_values[2]));
00574 }
00575 
00576 inline HxVec3Double
00577 HxVec3Double::log10() const
00578 {
00579     return HxVec3Double(::log10(_values[0]),
00580                         ::log10(_values[1]),
00581                         ::log10(_values[2]));
00582 }
00583 
00584 inline HxVec3Double&
00585 HxVec3Double::operator+=(const HxVec3Double& v)
00586 {
00587     _values[0] += v._values[0];
00588     _values[1] += v._values[1];
00589     _values[2] += v._values[2];
00590     return *this;
00591 }
00592 
00593 inline HxVec3Double&
00594 HxVec3Double::operator-=(const HxVec3Double& v)
00595 {
00596     _values[0] -= v._values[0];
00597     _values[1] -= v._values[1];
00598     _values[2] -= v._values[2];
00599     return *this;
00600 }
00601 
00602 inline HxVec3Double&
00603 HxVec3Double::operator*=(const HxVec3Double& v)
00604 {
00605     _values[0] *= v._values[0];
00606     _values[1] *= v._values[1];
00607     _values[2] *= v._values[2];
00608     return *this;
00609 }
00610 
00611 inline HxVec3Double&
00612 HxVec3Double::operator/=(const HxVec3Double& v)
00613 {
00614     _values[0] /= v._values[0];
00615     _values[1] /= v._values[1];
00616     _values[2] /= v._values[2];
00617     return *this;
00618 }
00619 
00620 inline HxVec3Double
00621 operator+(const HxVec3Double& v1, const HxVec3Double& v2)
00622 {
00623     return HxVec3Double(v1._values[0] + v2._values[0],
00624                         v1._values[1] + v2._values[1],
00625                         v1._values[2] + v2._values[2]);
00626 }
00627 
00628 inline HxVec3Double
00629 operator-(const HxVec3Double& v1, const HxVec3Double& v2)
00630 {
00631     return HxVec3Double(v1._values[0] - v2._values[0],
00632                         v1._values[1] - v2._values[1],
00633                         v1._values[2] - v2._values[2]);
00634 }
00635 
00636 inline HxVec3Double
00637 operator*(const HxVec3Double& v1, const HxVec3Double& v2)
00638 {
00639     return HxVec3Double(v1._values[0] * v2._values[0],
00640                         v1._values[1] * v2._values[1],
00641                         v1._values[2] * v2._values[2]);
00642 }
00643 
00644 inline HxVec3Double
00645 operator/(const HxVec3Double& v1, const HxVec3Double& v2)
00646 {
00647     return HxVec3Double(v1._values[0] / v2._values[0],
00648                         v1._values[1] / v2._values[1],
00649                         v1._values[2] / v2._values[2]);
00650 }
00651 
00652 inline HxVec3Double
00653 HxVec3Double::min(const HxVec3Double& v) const
00654 {
00655     return (operator<(v)) ? (*this) : v;
00656 }
00657 
00658 inline HxVec3Double&
00659 HxVec3Double::minAssign(const HxVec3Double& v)
00660 {
00661     if (operator<(v))
00662         return *this;
00663     operator=(v);
00664     return *this;
00665 }
00666 
00667 inline HxVec3Double
00668 HxVec3Double::max(const HxVec3Double& v) const
00669 {
00670     return (operator>(v)) ? (*this) : v;
00671 }
00672 
00673 inline HxVec3Double&
00674 HxVec3Double::maxAssign(const HxVec3Double& v)
00675 {
00676     if (operator>(v))
00677         return *this;
00678     operator=(v);
00679     return *this;
00680 }
00681 
00682 inline HxVec3Double
00683 HxVec3Double::inf(const HxVec3Double& v) const
00684 {
00685     return HxVec3Double((_values[0] < v._values[0]) ? _values[0] : v._values[0],
00686                         (_values[1] < v._values[1]) ? _values[1] : v._values[1],
00687                        (_values[2] < v._values[2]) ? _values[2] : v._values[2]);
00688 }
00689 
00690 inline HxVec3Double&
00691 HxVec3Double::infAssign(const HxVec3Double& v)
00692 {
00693     _values[0] = (_values[0] < v._values[0]) ? _values[0] : v._values[0];
00694     _values[1] = (_values[1] < v._values[1]) ? _values[1] : v._values[1];
00695     _values[2] = (_values[2] < v._values[2]) ? _values[2] : v._values[2];
00696     return *this;
00697 }
00698 
00699 inline HxVec3Double
00700 HxVec3Double::sup(const HxVec3Double& v) const
00701 {
00702     return HxVec3Double((_values[0] > v._values[0]) ? _values[0] : v._values[0],
00703                         (_values[1] > v._values[1]) ? _values[1] : v._values[1],
00704                        (_values[2] > v._values[2]) ? _values[2] : v._values[2]);
00705 }
00706 
00707 inline HxVec3Double&
00708 HxVec3Double::supAssign(const HxVec3Double& v)
00709 {
00710     _values[0] = (_values[0] > v._values[0]) ? _values[0] : v._values[0];
00711     _values[1] = (_values[1] > v._values[1]) ? _values[1] : v._values[1];
00712     _values[2] = (_values[2] > v._values[2]) ? _values[2] : v._values[2];
00713     return *this;
00714 }
00715 
00716 inline HxVec3Double
00717 HxVec3Double::pow(const HxVec3Double& v) const
00718 {
00719     return HxVec3Double(::pow(_values[0], v._values[0]),
00720                         ::pow(_values[1], v._values[1]),
00721                         ::pow(_values[2], v._values[2]));
00722 }
00723 
00724 inline HxVec3Double
00725 HxVec3Double::mod(const HxVec3Double&) const
00726 {
00727     return (*this);
00728 }
00729 
00730 inline HxVec3Double
00731 HxVec3Double::and(const HxVec3Double&) const
00732 {
00733     return (*this);
00734 }
00735 
00736 inline HxVec3Double
00737 HxVec3Double::or(const HxVec3Double&) const
00738 {
00739     return (*this);
00740 }
00741 
00742 inline HxVec3Double
00743 HxVec3Double::xor(const HxVec3Double&) const
00744 {
00745     return (*this);
00746 }
00747 
00748 inline HxVec3Double
00749 HxVec3Double::leftShift(const HxVec3Double&) const
00750 {
00751     return (*this);
00752 }
00753 
00754 inline HxVec3Double
00755 HxVec3Double::rightShift(const HxVec3Double&) const
00756 {
00757     return (*this);
00758 }
00759 
00760 inline HxVec3Double
00761 HxVec3Double::cross(const HxVec3Double& v) const
00762 {
00763     return HxVec3Double(_values[1] * v._values[2] - _values[2] * v._values[1],
00764                         _values[2] * v._values[0] - _values[0] * v._values[2],
00765                         _values[0] * v._values[1] - _values[1] * v._values[0]);
00766 }
00767 
00768 #endif

Generated on Tue Feb 3 14:18:44 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001