GOAT (Geometrical optics application tool) 0.1
Loading...
Searching...
No Matches
GOAT::raytracing::surface Class Reference

This class represents objects those surface is described by triangles. More...

#include <surface.h>

Inheritance diagram for GOAT::raytracing::surface:
GOAT::raytracing::ObjectShape

Public Member Functions

void addTriangle (triangle *S, int num)
 Adds triangles to the internal list of triangles.
void binRead (std::ifstream &is)
 Reads object from binary file represented by istream is.
void binWrite (std::ofstream &os)
 Writes object to binary file represented by ostream os.
maths::Vector< double > calcCoM ()
 calculates center of mass (needed by setCenter2CoM () )
void clearS ()
 clears the internal list of triangles
maths::Matrix< double > computeInertia ()
 Calculates the inertia of the object.
int createsurface ()
 Creates a list of triangles, which describes the surface, from standard input.
int createsurface (std::string FName)
 reads the triangle list from a file (proprietary file format, SRF)
void exportSRF (std::string FName)
 export triangle list to proprietary file format SRF
int getCurrentIndex ()
 Returns the index of the triangle that was last hit.
std::string getFilename ()
 returns the current file name
void getMinMax (double &min, double &max)
 calculates center of mass
trianglegetTriangle (int i)
 Returns the i-th triangle in the internal triangle list.
int importBinSTL (std::string FName)
 import triangle list from binary STL-file
void initBounds (maths::Vector< double > &pul, maths::Vector< double > &por)
 Calculates the bounding box (=circumferent cuboid) but without rotation. The cuboid is represented by the upper right corner (por) and the lower left corner (pul).
void initQuad ()
 Boundaries of the circumferent cuboid is calculated. The cuboid is represented by the upper right corner (por) and the lower left corner (pul). Used only for inelastic scattering.
bool isInside (const maths::Vector< double > &p)
 checks if point P is inside the object
bool next (const maths::Vector< double > &r, const maths::Vector< double > &k, maths::Vector< double > &p)
 Calculates the intersection point between a straight line and the surface object. The straight line is represented by a point on the line and its direction.
maths::Vector< double > norm (const maths::Vector< double > &P)
 Surface normal at point P (There is no check, if P is on the surface. This function is used for internal purposes)
surface nosurface ()
 returns copy of the object without triangles
surfaceoperator= (const surface &)
void scale (double sf)
 scale the lengths of all triangles
void setCenter (maths::Vector< double > P)
void setCenter2CoM ()
 Sets the Position to the center of mass (CoM)
void setFilename (std::string FName)
void setPos (double x, double y, double z)
 Set position of the object to a position vector represented by its components x,y and z.
void setPos (maths::Vector< double > r)
 Set position of the object to r.
void setr0 (double r0)
 sets the radius of the calculation sphere (necessary only if this class is used outside Scene)
 surface ()
 surface (const maths::Vector< double > &P, std::complex< double > n, const maths::Matrix< std::complex< double > > alpha=maths::CUNITY, const maths::Vector< double > Ex=GOAT::maths::ex, const maths::Vector< double > Ey=GOAT::maths::ey, const maths::Vector< double > Ez=GOAT::maths::ez)
 surface (const maths::Vector< double > &P, std::complex< double > n, int num, triangle *list, 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)
 surface (const surface &Su)
 surface (maths::Vector< double > Oh)
 Empty surface object with position Oh.
double volume ()
 Calculates the volume of the object.
Public Member Functions inherited from GOAT::raytracing::ObjectShape
std::complex< double > getn ()
 returns refractive index for inelastic (RRT) calculation
std::complex< double > getninel ()
 returns refractive index
bool getVisible ()
 show the visiblity state (used in GOATvis)
bool isActive ()
 returns true if the object should be considered for inelastic calculation
bool isOutsideWorld ()
 Test if bounding box is (partly) outside the calculation space.
 ObjectShape ()
 ObjectShape (const maths::Vector< double > &P, std::complex< double > n, GOAT::maths::Matrix< std::complex< double > > alpha, const maths::Vector< double > &Ex=maths::ex, const maths::Vector< double > &Ey=maths::ey, const maths::Vector< double > &Ez=maths::ez, const int type=-1)
 Constructor, as template for all derived classes.
 ObjectShape (const ObjectShape &F)
void rotate (maths::Vector< double > A, double phi)
 sets the matrix for the transformation between object's coordinate system and outer coordinate system, A: rotation axis, phi: angle for rotation around A
void scale (double sf)
 sets scaling of the shape by the factor sf
void setActive (bool active)
 sets flag if the object is inelastic active, i.e. it will be considered for inelastic calculation
void setAlpha (double Alpha)
 sets rotation angle around x-axis
void setBeta (double Beta)
 sets rotation angle around y-axis
void setCenter (maths::Vector< double > P)
 sets Center to P (check, if function is necessary)
void setCenter2CoM ()
 Calculates the center of mass (CoM) and sets the object's reference point to the CoM.
void setGamma (double Gamma)
 sets rotation angle around z-axis
void setMatrix (double alpha, double beta, double gamma)
 sets the matrix for the transformation between object's coordinate system and outer coordinate system, alpha, beta, gamma: angles (rotation around x-, y- and z-axis) to calculate transformation matrix
void setMatrix (maths::Matrix< double > H)
 sets the matrix for the transformation between object's coordinate system and outer coordinate system, H: transformation matrix
void setn (std::complex< double > n)
 sets refractive index
void setninel (std::complex< double > ninel)
 sets refractive index for inelastic (RRT) calculation
void setPolMatrix (maths::Matrix< std::complex< double > >alpha)
 sets polarisability matrix
void setVisible (bool visible)
 set visiblity (used in GOATvis)
int Type ()
 returns the object's type

Public Attributes

int currentIndex
 Index of the triangle that was last hit.
maths::Vector< double > currentnorm
 Normal vector of the triangle that was last hit.
int filetype =OBJECTSHAPE_SURFACE_FILETYPE_NONE
 type of the file connected with this surface object
std::string FName
 File name (used to save the internal triangle list)
int numTriangles = 0
 number of triangles
triangleS
 list of all triangles
Public Attributes inherited from GOAT::raytracing::ObjectShape
bool Active
 should the object be considered for inelastic (RRT) calculations?
maths::Matrix< std::complex< double > > alpha
 polarisability matrix
maths::Vector< double > e [3]
 unity vectors, describing the directions of the local coordinate system
double Ealpha
double Ebeta
double Egamma
 angles through which the object was rotated (around the x- (Ealpha), then the y- (Ebeta) and finally the z-axis (Egamma))
maths::Matrix< double > H
std::complex< double > n
 refractive index of the object
std::function< std::complex< double >(double)> nfunc
NFUNCTYPE nfuncType =NFUNCTYPE::vacuum
std::complex< double > ninel
 refractive index of the object, used for inelastic (RRT) calculation
maths::Vector< double > P
 position of the object
maths::Vector< double > por
 corners of the circumferent cuboid (lower left corner and upper right corner)
maths::Vector< double > pul
maths::Matrix< double > R
 matrices for the transformation in the local coordinate system (H) and back to the calculation system (R)
double r0
 radius of the calculation sphere
double rho
 mass density in \( kg/m^3 \)
double sf =1
 scaling factor, it is used to scale the shape of the object
int type
 type of the object
bool visible =true

Detailed Description

This class represents objects those surface is described by triangles.

The surface class represents a volume object, whose surface is described by triangles. This method is often used by CAD programs, therefore a function is provided to import binary stl files. The surface class has also a simple proprietary file format: The first entry is the number of triangles in the file. Than, the information about the triangles follows. Each triangle is described by the components of the corner vectors. Therefore the file looks like: \(\newline \begin{array}{ccccccccc} \text{<number of triangles>} & & & & & & & & \\ \text{<number of triangles>} & & & & & & & & \\ x_{00} & y_{00} & z_{00} & x_{01} & y_{01} & z_{01} & x_{02} & y_{02} & z_{02} \\ x_{10} & y_{10} & z_{10} & x_{11} & y_{11} & z_{11} & x_{12} & y_{12} & z_{12} \\ \vdots & \vdots & & & & & & & \end{array} \) The intersection points are calculated with help of an octree procedure to enhance the calculation speed for the intersection point finding.

Definition at line 55 of file surface.h.

Constructor & Destructor Documentation

◆ surface() [1/5]

GOAT::raytracing::surface::surface ( )

◆ surface() [2/5]

GOAT::raytracing::surface::surface ( maths::Vector< double > Oh)

Empty surface object with position Oh.

◆ surface() [3/5]

GOAT::raytracing::surface::surface ( const surface & Su)

◆ surface() [4/5]

GOAT::raytracing::surface::surface ( const maths::Vector< double > & P,
std::complex< double > n,
const maths::Matrix< std::complex< double > > alpha = maths::CUNITY,
const maths::Vector< double > Ex = GOAT::maths::ex,
const maths::Vector< double > Ey = GOAT::maths::ey,
const maths::Vector< double > Ez = GOAT::maths::ez )

Constructor for an empty surface object.

Parameters
Pposition of the object
nrefractive index
alphapolarisability
Exdirection of the first axis of the local coordinate system (usually ex)
Eydirection of the second axis of the local coordinate system (usually ey)
Ezdirection of the third axis of the local coordinate system (usually ez)

◆ surface() [5/5]

GOAT::raytracing::surface::surface ( const maths::Vector< double > & P,
std::complex< double > n,
int num,
triangle * list,
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 )

Constructor for an object, whose surface is described by a list of triangles

Parameters
Pposition of the object
nrefractive index
numnumber of triangles
listlist of triangles
alphapolarisability
Exdirection of the first axis of the local coordinate system (usually ex)
Eydirection of the second axis of the local coordinate system (usually ey)
Ezdirection of the third axis of the local coordinate system (usually ez)

Member Function Documentation

◆ addTriangle()

void GOAT::raytracing::surface::addTriangle ( triangle * S,
int num )

Adds triangles to the internal list of triangles.

Parameters
Slist of triangles
numnumber of triangles to add

◆ binRead()

void GOAT::raytracing::surface::binRead ( std::ifstream & is)
virtual

Reads object from binary file represented by istream is.

Implements GOAT::raytracing::ObjectShape.

◆ binWrite()

void GOAT::raytracing::surface::binWrite ( std::ofstream & os)
virtual

Writes object to binary file represented by ostream os.

Implements GOAT::raytracing::ObjectShape.

◆ calcCoM()

maths::Vector< double > GOAT::raytracing::surface::calcCoM ( )
virtual

calculates center of mass (needed by setCenter2CoM () )

Implements GOAT::raytracing::ObjectShape.

◆ clearS()

void GOAT::raytracing::surface::clearS ( )

clears the internal list of triangles

◆ computeInertia()

maths::Matrix< double > GOAT::raytracing::surface::computeInertia ( )

Calculates the inertia of the object.

◆ createsurface() [1/2]

int GOAT::raytracing::surface::createsurface ( )

Creates a list of triangles, which describes the surface, from standard input.

◆ createsurface() [2/2]

int GOAT::raytracing::surface::createsurface ( std::string FName)

reads the triangle list from a file (proprietary file format, SRF)

◆ exportSRF()

void GOAT::raytracing::surface::exportSRF ( std::string FName)

export triangle list to proprietary file format SRF

◆ getCurrentIndex()

int GOAT::raytracing::surface::getCurrentIndex ( )
inline

Returns the index of the triangle that was last hit.

Definition at line 174 of file surface.h.

◆ getFilename()

std::string GOAT::raytracing::surface::getFilename ( )
inline

returns the current file name

Definition at line 141 of file surface.h.

◆ getMinMax()

void GOAT::raytracing::surface::getMinMax ( double & min,
double & max )

calculates center of mass

Returns the smallest and largest edge length of the triangles stored in the surface object

Parameters
minsmallest edge length
maxlargest edge length

◆ getTriangle()

triangle & GOAT::raytracing::surface::getTriangle ( int i)
inline

Returns the i-th triangle in the internal triangle list.

Definition at line 175 of file surface.h.

◆ importBinSTL()

int GOAT::raytracing::surface::importBinSTL ( std::string FName)

import triangle list from binary STL-file

◆ initBounds()

void GOAT::raytracing::surface::initBounds ( maths::Vector< double > & pul,
maths::Vector< double > & por )

Calculates the bounding box (=circumferent cuboid) but without rotation. The cuboid is represented by the upper right corner (por) and the lower left corner (pul).

◆ initQuad()

void GOAT::raytracing::surface::initQuad ( )
virtual

Boundaries of the circumferent cuboid is calculated. The cuboid is represented by the upper right corner (por) and the lower left corner (pul). Used only for inelastic scattering.

Implements GOAT::raytracing::ObjectShape.

◆ isInside()

bool GOAT::raytracing::surface::isInside ( const maths::Vector< double > & p)
virtual

checks if point P is inside the object

Implements GOAT::raytracing::ObjectShape.

◆ next()

bool GOAT::raytracing::surface::next ( const maths::Vector< double > & r,
const maths::Vector< double > & k,
maths::Vector< double > & p )
virtual

Calculates the intersection point between a straight line and the surface object. The straight line is represented by a point on the line and its direction.

Parameters
rpoint on the line
directionof the line
pcalculated intersection point (zero, if there is no intersection at all)
Returns
true if there is an intersection point otherwise false

Implements GOAT::raytracing::ObjectShape.

◆ norm()

maths::Vector< double > GOAT::raytracing::surface::norm ( const maths::Vector< double > & P)
virtual

Surface normal at point P (There is no check, if P is on the surface. This function is used for internal purposes)

Implements GOAT::raytracing::ObjectShape.

◆ nosurface()

surface GOAT::raytracing::surface::nosurface ( )

returns copy of the object without triangles

◆ operator=()

surface & GOAT::raytracing::surface::operator= ( const surface & )

◆ scale()

void GOAT::raytracing::surface::scale ( double sf)

scale the lengths of all triangles

Parameters
sfscaling factor

◆ setCenter()

void GOAT::raytracing::surface::setCenter ( maths::Vector< double > P)

◆ setCenter2CoM()

void GOAT::raytracing::surface::setCenter2CoM ( )

Sets the Position to the center of mass (CoM)

◆ setFilename()

void GOAT::raytracing::surface::setFilename ( std::string FName)
inline
Parameters
FNameset the current file name

Definition at line 142 of file surface.h.

◆ setPos() [1/2]

void GOAT::raytracing::surface::setPos ( double x,
double y,
double z )
inlinevirtual

Set position of the object to a position vector represented by its components x,y and z.

Implements GOAT::raytracing::ObjectShape.

Definition at line 166 of file surface.h.

◆ setPos() [2/2]

void GOAT::raytracing::surface::setPos ( maths::Vector< double > r)
virtual

Set position of the object to r.

Implements GOAT::raytracing::ObjectShape.

◆ setr0()

void GOAT::raytracing::surface::setr0 ( double r0)
virtual

sets the radius of the calculation sphere (necessary only if this class is used outside Scene)

Implements GOAT::raytracing::ObjectShape.

◆ volume()

double GOAT::raytracing::surface::volume ( )
virtual

Calculates the volume of the object.

Implements GOAT::raytracing::ObjectShape.

Member Data Documentation

◆ currentIndex

int GOAT::raytracing::surface::currentIndex

Index of the triangle that was last hit.

Definition at line 180 of file surface.h.

◆ currentnorm

maths::Vector<double> GOAT::raytracing::surface::currentnorm

Normal vector of the triangle that was last hit.

Definition at line 179 of file surface.h.

◆ filetype

int GOAT::raytracing::surface::filetype =OBJECTSHAPE_SURFACE_FILETYPE_NONE

type of the file connected with this surface object

Definition at line 176 of file surface.h.

◆ FName

std::string GOAT::raytracing::surface::FName

File name (used to save the internal triangle list)

Definition at line 181 of file surface.h.

◆ numTriangles

int GOAT::raytracing::surface::numTriangles = 0

number of triangles

Definition at line 112 of file surface.h.

◆ S

triangle* GOAT::raytracing::surface::S

list of all triangles

Definition at line 111 of file surface.h.


The documentation for this class was generated from the following file: