GOAT (Geometrical optics application tool) 0.1
Loading...
Searching...
No Matches
box.h
Go to the documentation of this file.
1#pragma once
2#include "objectshape.h"
3#include <iostream>
4
5
6
7
8namespace GOAT
9{
10 namespace raytracing
11 {
16 class Box :
17 public ObjectShape
18 {
19
20 private:
21 bool isOctree = false;
22
23 public:
24 Box();
25 Box(const ObjectShape& F);
26 Box(const Box& B);
41 std::complex<double> n,
42 double r0 = 1.0,
43 const maths::Matrix<std::complex<double> > alpha = maths::CUNITY,
44 const maths::Vector<double> Ex = maths::ex,
45 const maths::Vector<double> Ey = maths::ey,
46 const maths::Vector<double> Ez = maths::ez);
53 Box(const maths::Vector<double> bound0, const maths::Vector<double> bound1);
54 ~Box();
55 void binWrite(std::ofstream& os);
56 void binRead(std::ifstream& is);
57 void scale(double sf);
62 double volume() { return abs2(d); }
63 double getSize() { return abs(bounds[1] - bounds[0]); }
64 void initQuad();
65 void setr0(double r0);
66 void calcDiag()
67 {
68 diag[0] = bounds[1] - bounds[0];
69 diag[1] = maths::Vector<double>(-diag[0][0], diag[0][1], diag[0][2]);
70 diag[2] = maths::Vector<double>(-diag[0][0], -diag[0][1], diag[0][2]);
71 }
72
74 {
75 P = r;
76 bounds[0] = P - d / 2.0;
77 bounds[1] = P + d / 2.0;
78 pul = bounds[0];
79 por = bounds[1];
80 }
81 void setPos(double x, double y, double z) { setPos(maths::Vector<double>(x, y, z)); }
82 maths::Vector<double> getD() const { return d; }
84 {
85 d = D;
86 bounds[0] = P - d / 2.0;
87 bounds[1] = P + d / 2.0;
88 }
89
90
91
95 maths::Vector<double> calcCoM() { return maths::dzero; }
96 void setOctree(bool isOctree) { this->isOctree = isOctree; }
97 };
98
99 std::ostream& operator<< (std::ostream& os, Box B);
100 }
101}
This class represents a threedimensional (numeric) Matrix as a template.
Definition matrix.h:23
Template class for threedimensional vectors.
Definition vector.h:57
class which represents a box (cuboid). It is derived by class ObjectShape This class is mainly used f...
Definition box.h:18
void binWrite(std::ofstream &os)
writes object to a binary file
bool next(const maths::Vector< double > &p, const maths::Vector< double > &k, maths::Vector< double > &pout)
calculates the next crossing point between a ray represented by the position
Box(const Box &B)
copy constructor
double distance(const maths::Vector< double > &p, const maths::Vector< double > &k)
calculates the distance between a ray, described by the position vector p and its directional vector ...
void setPos(double x, double y, double z)
sets the position P and the corresponding bounds
Definition box.h:81
Box(const maths::Vector< double > &P, const maths::Vector< double > &d, std::complex< double > n, double r0=1.0, const maths::Matrix< std::complex< double > > alpha=maths::CUNITY, const maths::Vector< double > Ex=maths::ex, const maths::Vector< double > Ey=maths::ey, const maths::Vector< double > Ez=maths::ez)
void scale(double sf)
sets scaling factor
bool isOctree
used for Octree calculation
Definition box.h:21
maths::Vector< double > bounds[2]
positions of the two opposite corners (with box in the center)
Definition box.h:92
void binRead(std::ifstream &is)
reads object from a binary file
void calcDiag()
Definition box.h:66
Box(const ObjectShape &F)
maths::Vector< double > d
extensions of the box in x-, y- and z-direction
Definition box.h:93
Box(const maths::Vector< double > bound0, const maths::Vector< double > bound1)
maths::Vector< double > getD() const
getthe Size of the box as a vector with its edge lenghts
Definition box.h:82
void initQuad()
calculates the circumferent cuboid
bool isInside(const maths::Vector< double > &Ps)
returns true, if Ps is inside the box
maths::Vector< double > norm(const maths::Vector< double > &p)
normal vector at the position p
void setPos(maths::Vector< double > r)
sets reference point P
Definition box.h:73
void setr0(double r0)
sets the radius of the calculation sphere
maths::Vector< double > calcCoM()
calculates center of mass (needed by setCenter2CoM () )
Definition box.h:95
double getSize()
returns a vector with the side lengths as its components
Definition box.h:63
double volume()
returns the volume of the box
Definition box.h:62
void setOctree(bool isOctree)
box belongs to an octree calculation
Definition box.h:96
void setD(maths::Vector< double > D)
Definition box.h:83
maths::Vector< double > diag[3]
diagonal
Definition box.h:94
double sf
scaling factor, it is used to scale the shape of the object
maths::Vector< double > por
corners of the circumferent cuboid (lower left corner and upper right corner)
maths::Matrix< std::complex< double > > alpha
polarisability matrix
maths::Vector< double > pul
maths::Vector< double > P
position of the object
double r0
radius of the calculation sphere
std::complex< double > n
refractive index of the object
const Matrix< std::complex< double > > CUNITY
Unity matrix (complex-valued)
Definition matrix.h:475
Raytracer used for ultrashort pulse calculation with raytracing only.
Definition asphericLens.h:6
double abs2(double x)
returns the squared absolute value of x
std::ostream & operator<<(std::ostream &os, Box B)
output operator for the Box class
This class is used for the iray class. This class is intended for internal use only....
Definition fresnel.h:7