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

HxVectorR2.h

00001 /*
00002  *  Copyright (c) 1999, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *
00006  *  Author(s):
00007  *  Silvia D. Olabarriaga  (silvia@wins.uva.nl)
00008  *  Dennis Koelma (koelma@wins.uva.nl)
00009  */
00010 
00011 #ifndef HxVectorR2_h
00012 #define HxVectorR2_h
00013 
00014 #include "HxIoFwd.h"
00015 #include "HxVec2Double.h"
00016 #include "HxScalarDouble.h"
00017 
00018 class HxPointR2;
00019 
00022 class HxVectorR2 {
00023 public:
00025                     HxVectorR2();
00026 
00028                     HxVectorR2(double d1, double d2);
00029 
00031                     HxVectorR2(const HxPointR2& p1, const HxPointR2& p2);   
00032 
00033 
00035     double          x() const;
00036 
00038     double          y() const;
00039 
00041     HxVectorR2      add(const HxVectorR2& arg) const;
00042 
00044     HxVectorR2      sub(const HxVectorR2& arg) const;
00045 
00047     HxVectorR2      mul(double arg) const;
00048 
00050     HxVectorR2      div(double arg) const;
00051 
00053     double          dot(const HxVectorR2& arg) const;
00054 
00056     double          cross2D(const HxVectorR2& arg) const;
00057 
00059     double          magnitude() const;
00060     
00062     double          squaredMagnitude() const;
00063 
00065     HxVectorR2      normal() const; 
00066 
00068     STD_OSTREAM&    put(STD_OSTREAM&) const;
00069 
00070     STD_OSTREAM&    dump(HxVectorR2&) const;
00071     HxString        toString() const;
00072 
00073 private:
00074     friend class HxPointR2;
00075 
00076     HxVec2Double    _data;
00077 };
00078 
00079 
00080 inline STD_OSTREAM&
00081 operator<<(STD_OSTREAM& os, const HxVectorR2 v)
00082 {
00083     return v.put(os);
00084 }
00085 
00086 inline
00087 HxVectorR2::HxVectorR2() : _data(0,0)
00088 {
00089 }
00090 
00091 inline
00092 HxVectorR2::HxVectorR2(double d1, double d2) : _data(d1, d2)
00093 {
00094 }
00095 
00096 inline double
00097 HxVectorR2::x() const
00098 {
00099     return _data.x();
00100 }
00101 
00102 inline double
00103 HxVectorR2::y() const
00104 {
00105     return _data.y();
00106 }
00107 
00108 inline HxVectorR2 
00109 HxVectorR2::add(const HxVectorR2& arg) const
00110 {
00111     return HxVectorR2( _data.x()+arg.x(), _data.y()+arg.y()); 
00112 }
00113 
00114 inline HxVectorR2 
00115 HxVectorR2::sub(const HxVectorR2& arg) const
00116 {
00117     return HxVectorR2( _data.x()-arg.x(), _data.y()-arg.y()); 
00118 }
00119 
00120 inline HxVectorR2 
00121 HxVectorR2::mul(double arg) const
00122 {
00123     return HxVectorR2( _data.x()*arg, _data.y()*arg); 
00124 }
00125 
00126 inline HxVectorR2 
00127 HxVectorR2::div(double arg) const
00128 {
00129     return HxVectorR2( _data.x()/arg, _data.y()/arg); 
00130 }
00131 
00132 inline double 
00133 HxVectorR2::dot(const HxVectorR2& arg) const
00134 {
00135     return _data.dot(arg._data).x();
00136 }
00137 
00138 inline double 
00139 HxVectorR2::cross2D(const HxVectorR2& arg) const
00140 {
00141     return _data.x()*arg.y() + _data.y()*arg.x();
00142 }
00143 
00144 inline double 
00145 HxVectorR2::magnitude() const
00146 {
00147     return _data.norm2().x();
00148 }
00149 
00150 inline double 
00151 HxVectorR2::squaredMagnitude() const
00152 {
00153     return _data.x()*_data.x() + _data.y()*_data.y();
00154 }
00155 
00156 inline HxVectorR2
00157 HxVectorR2::normal() const
00158 {
00159     return HxVectorR2(_data.y(), -_data.x()); 
00160 }
00161 
00162 inline HxString
00163 HxVectorR2::toString() const
00164 {
00165     return _data.toString();
00166 }
00167 
00168 inline STD_OSTREAM& 
00169 HxVectorR2::put(STD_OSTREAM& os) const
00170 {
00171     return os << _data;
00172 }
00173 
00174 inline HxString
00175 makeString(const HxVectorR2& v)
00176 {
00177     return v.toString();
00178 }
00179 
00180 #endif

Generated on Mon Jan 27 15:48:50 2003 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001