00001 #ifndef rl_BasicRay_h_INCLUDED
00002 #define rl_BasicRay_h_INCLUDED
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <dvm3/dvm3.h>
00032 #include <rl_basicray/rl_RayMath.h>
00033 #include <Exception/Exception.h>
00034
00035
00036
00037
00038
00039
00047 class rl_BasicRay
00048 {
00049 protected:
00050
00052 dvm3_Vector pos_;
00054 dvm3_Vector dir_;
00056 double energy_;
00058 long int id_;
00059
00069 void init( dvm3_Vector const& pos, dvm3_Vector const& dir,
00070 double energy, long int id );
00071
00072 public:
00073
00075 virtual ~rl_BasicRay();
00076
00077
00082 rl_BasicRay();
00083
00094 rl_BasicRay( dvm3_Vector const& pos, dvm3_Vector const& dir,
00095 double energy, long int id );
00096
00102 rl_BasicRay( rl_BasicRay const& other );
00103
00109 void set_id( long int id );
00110
00116 long int id() const;
00117
00123 double& energy();
00124
00130 double energy() const;
00131
00139 double& position( int i );
00140
00148 double position( int i ) const;
00149
00155 dvm3_Vector& position();
00156
00162 dvm3_Vector const& position() const;
00163
00169 double& direction( int i );
00170
00178 double direction( int i ) const;
00179
00185 dvm3_Vector& direction();
00186
00192 dvm3_Vector const& direction() const;
00193
00202 double reflect_direction_vector( dvm3_Vector const& normal );
00203
00209 void project( double s );
00210
00218 virtual
00219 void translate_rotate( dvm3_Vector const& trans,
00220 dvm3_RotMat const& rotmat );
00221
00230 virtual
00231 void derotate_detranslate( dvm3_Vector const& trans,
00232 dvm3_RotMat const& rotmat );
00233
00243 std::ostream& print_on( std::ostream& os, char const prefix[] = "",
00244 char const postfix[] = "" ) const;
00245
00253 friend std::ostream& operator<<( std::ostream& os, rl_BasicRay const& );
00254 };
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273 inline rl_BasicRay::
00274 rl_BasicRay()
00275 {}
00276
00277
00278 inline rl_BasicRay::
00279 rl_BasicRay( dvm3_Vector const& pos, dvm3_Vector const& dir,
00280 double energy, long int id )
00281 : pos_(pos), dir_(dir), energy_(energy), id_(id)
00282 {}
00283
00284
00285 inline rl_BasicRay::
00286 rl_BasicRay( rl_BasicRay const& other )
00287 : pos_(other.pos_), dir_(other.dir_), energy_(other.energy_), id_(other.id_)
00288 {}
00289
00290
00291 inline void rl_BasicRay::
00292 init( dvm3_Vector const& pos, dvm3_Vector const& dir,
00293 double energy, long int id )
00294 {
00295 pos_ = pos;
00296 dir_ = dir;
00297 energy_ = energy;
00298 id_ = id;
00299 }
00300
00301
00302
00303
00304
00305 inline long int rl_BasicRay::
00306 id() const
00307 { return id_; }
00308
00309 inline void rl_BasicRay::
00310 set_id( long int id )
00311 { id_ = id; }
00312
00313
00314 inline double& rl_BasicRay::
00315 energy()
00316 { return energy_; }
00317
00318
00319 inline double rl_BasicRay::
00320 energy() const
00321 { return energy_; }
00322
00323
00324 inline double& rl_BasicRay::
00325 position( int i )
00326 { return pos_[i]; }
00327
00328
00329 inline double rl_BasicRay::
00330 position( int i ) const
00331 { return pos_[i]; }
00332
00333
00334 inline dvm3_Vector& rl_BasicRay::
00335 position()
00336 { return pos_; }
00337
00338
00339 inline dvm3_Vector const& rl_BasicRay::
00340 position() const
00341 { return pos_; }
00342
00343
00344 inline double& rl_BasicRay::
00345 direction( int i )
00346 { return dir_[i]; }
00347
00348
00349 inline double rl_BasicRay::
00350 direction( int i ) const
00351 { return dir_[i]; }
00352
00353
00354 inline dvm3_Vector& rl_BasicRay::
00355 direction()
00356 { return dir_; }
00357
00358
00359 inline dvm3_Vector const& rl_BasicRay::
00360 direction() const
00361 { return dir_; }
00362
00363
00364
00365
00366
00367 inline
00368 void rl_BasicRay::
00369 project( double s )
00370 {
00371 pos_ += s * dir_;
00372 }
00373
00374
00375
00376
00377
00378 inline void rl_BasicRay::
00379 translate_rotate( dvm3_Vector const& trans,
00380 dvm3_RotMat const& rotmat )
00381 {
00382 rl_RayMath::translate_rotate( trans, rotmat, pos_ );
00383 rl_RayMath::rotate( rotmat, dir_ );
00384 }
00385
00386
00387
00388
00389
00390 inline void rl_BasicRay::
00391 derotate_detranslate( dvm3_Vector const& trans,
00392 dvm3_RotMat const& rotmat )
00393 {
00394 rl_RayMath::derotate_detranslate( trans, rotmat, pos_ );
00395 rl_RayMath::derotate( rotmat, dir_ );
00396 }
00397
00398
00399 #endif