Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
JGEOMETRY3D::JOmega3S_t Struct Reference

Auxiliary data structure to group direction sets. More...

#include <JOmega3D.hh>

Inheritance diagram for JGEOMETRY3D::JOmega3S_t:
JGEOMETRY3D::JAngle3D JGEOMETRY3D::JOmega3D JMATH::JMath< JFirst_t, JSecond_t > JGEOMETRY3D::JOmega3D_t std::vector< JAngle3D >

Public Types

typedef std::pair< double, double > range_type
 

Public Member Functions

double getTheta () const
 Get theta angle.
 
double getPhi () const
 Get phi angle.
 
double getDX () const
 Get x direction.
 
double getDY () const
 Get y direction.
 
double getDZ () const
 Get z direction.
 
JAngle3D & negate ()
 Negate angle.
 
JAngle3D & add (const JAngle3D &angle)
 Add angle.
 
JAngle3D & sub (const JAngle3D &angle)
 Subtract angle.
 
JAngle3D & mul (const double factor)
 Scale angle.
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object.
 
JAngle3D & div (const double factor)
 Scale angle.
 
bool equals (const JAngle3D &angle, const double precision=std::numeric_limits< double >::min()) const
 Check equality.
 
double getDot (const JAngle3D &angle) const
 Get dot product.
 
JAngle3D & normalise ()
 Normalise angles.
 
void configure (const JAngle3D &dir, const range_type &theta, const double grid)
 Configure direction set.
 
int find (const JAngle3D &dir) const
 Get index of direction closest to given direction.
 

Static Public Member Functions

static double getAngle (const size_t N)
 Get approximate angular spacing given number of directions.
 

Protected Attributes

double __theta
 
double __phi
 

Detailed Description

Auxiliary data structure to group direction sets.

Definition at line 186 of file JOmega3D.hh.

Member Typedef Documentation

◆ range_type

Definition at line 32 of file JOmega3D.hh.

Member Function Documentation

◆ getTheta()

double JGEOMETRY3D::JAngle3D::getTheta ( ) const
inlineinherited

Get theta angle.

Returns
theta angle

Definition at line 86 of file JAngle3D.hh.

87 {
88 return __theta;
89 }

◆ getPhi()

double JGEOMETRY3D::JAngle3D::getPhi ( ) const
inlineinherited

Get phi angle.

Returns
phi angle

Definition at line 97 of file JAngle3D.hh.

98 {
99 return __phi;
100 }

◆ getDX()

double JGEOMETRY3D::JAngle3D::getDX ( ) const
inlineinherited

Get x direction.

Returns
x direction

Definition at line 108 of file JAngle3D.hh.

109 {
110 return sin(__theta) * cos(__phi);
111 }

◆ getDY()

double JGEOMETRY3D::JAngle3D::getDY ( ) const
inlineinherited

Get y direction.

Returns
y direction

Definition at line 119 of file JAngle3D.hh.

120 {
121 return sin(__theta) * sin(__phi);
122 }

◆ getDZ()

double JGEOMETRY3D::JAngle3D::getDZ ( ) const
inlineinherited

Get z direction.

Returns
z direction

Definition at line 130 of file JAngle3D.hh.

131 {
132 return cos(__theta);
133 }

◆ negate()

JAngle3D & JGEOMETRY3D::JAngle3D::negate ( )
inlineinherited

Negate angle.

Returns
this angle

Definition at line 141 of file JAngle3D.hh.

142 {
143 __theta = -__theta;
144 __phi = -__phi;
145
146 return *this;
147 }

◆ add()

JAngle3D & JGEOMETRY3D::JAngle3D::add ( const JAngle3D & angle)
inlineinherited

Add angle.

Parameters
angleangle
Returns
this angle

Definition at line 156 of file JAngle3D.hh.

157 {
158 __theta += angle.getTheta();
159 __phi += angle.getPhi();
160
161 return *this;
162 }

◆ sub()

JAngle3D & JGEOMETRY3D::JAngle3D::sub ( const JAngle3D & angle)
inlineinherited

Subtract angle.

Parameters
angleangle
Returns
this angle

Definition at line 171 of file JAngle3D.hh.

172 {
173 __theta -= angle.getTheta();
174 __phi -= angle.getPhi();
175
176 return *this;
177 }

◆ mul() [1/2]

JAngle3D & JGEOMETRY3D::JAngle3D::mul ( const double factor)
inlineinherited

Scale angle.

Parameters
factormultiplication factor
Returns
this angle

Definition at line 185 of file JAngle3D.hh.

186 {
187 __theta *= factor;
188 __phi *= factor;
189
190 return *this;
191 }

◆ mul() [2/2]

template<class JFirst_t , class JSecond_t >
JFirst_t & JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t & object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355 {
356 return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357 }

◆ div()

JAngle3D & JGEOMETRY3D::JAngle3D::div ( const double factor)
inlineinherited

Scale angle.

Parameters
factordivision factor
Returns
this angle

Definition at line 200 of file JAngle3D.hh.

201 {
202 __theta /= factor;
203 __phi /= factor;
204
205 return *this;
206 }

◆ equals()

bool JGEOMETRY3D::JAngle3D::equals ( const JAngle3D & angle,
const double precision = std::numeric_limits<double>::min() ) const
inlineinherited

Check equality.

Parameters
angleangle
precisionprecision
Returns
true if angles are equal; else false

Definition at line 216 of file JAngle3D.hh.

218 {
219 return (fabs(getTheta() - angle.getTheta()) <= precision &&
220 fabs(getPhi() - angle.getPhi()) <= precision);
221 }
double getTheta() const
Get theta angle.
Definition JAngle3D.hh:86
double getPhi() const
Get phi angle.
Definition JAngle3D.hh:97

◆ getDot()

double JGEOMETRY3D::JAngle3D::getDot ( const JAngle3D & angle) const
inlineinherited

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 230 of file JAngle3D.hh.

231 {
232 return
233 cos(getTheta()) * cos(angle.getTheta()) +
234 sin(getTheta()) * sin(angle.getTheta()) *
235 cos(getPhi() - angle.getPhi());
236 }

◆ normalise()

JAngle3D & JGEOMETRY3D::JAngle3D::normalise ( )
inlineinherited

Normalise angles.

  • theta angle will be between 0 and π
  • phi angle will be between -π and +π
Returns
this angle

Definition at line 247 of file JAngle3D.hh.

248 {
249 using JMATH::PI;
250
251 if (__theta > PI) { do { __theta -= PI; } while (__theta > PI); }
252 if (__theta < 0.0) { do { __theta += PI; } while (__theta < 0.0); }
253
254 if (__phi > +PI) { do { __phi -= 2*PI; } while (__phi > +PI); }
255 if (__phi < -PI) { do { __phi += 2*PI; } while (__phi < -PI); }
256
257 return *this;
258 }
static const double PI
Mathematical constants.

◆ configure()

void JGEOMETRY3D::JOmega3D::configure ( const JAngle3D & dir,
const range_type & theta,
const double grid )
inlineinherited

Configure direction set.

Parameters
dirprincipal direction
thetapolar angle range [rad]
gridangular spacing [rad]

Definition at line 126 of file JOmega3D.hh.

129 {
130 clear();
131
132 // sanity checks
133
134 double thetaMin = theta.first;
135 double thetaMax = theta.second;
136
137 if (thetaMin < 0.0) { thetaMin = 0.0; }
138 if (thetaMin > PI) { thetaMin = PI; }
139 if (thetaMax < 0.0) { thetaMax = 0.0; }
140 if (thetaMax > PI) { thetaMax = PI; }
141
142 if (thetaMax > thetaMin) {
143
144 const JRotation3D R(dir);
145
146 const double rad = thetaMax - thetaMin;
147 const double bin = rad / floor(rad/(1.4*grid) + 0.5); // polar angle step size
148 const double unit = 2.0 * sqrt(1.0 - cos(grid)); // azimuth angle unit step size
149
150 for (double theta = thetaMin; theta < thetaMax + 0.5*bin; theta += bin) {
151
152 double step;
153
154 if (theta > 0.5*bin && PI - theta > 0.5*bin)
155 step = PI / floor(PI*sin(theta)/unit + 0.5); // polar angle dependent step size
156 else
157 step = 2.0*PI; // pole
158
159 for (double phi = 0.0; phi < 2.0*PI - 0.5*step; phi += step) {
160 push_back(JDirection3D(JAngle3D(theta,phi)).rotate_back(R));
161 }
162 }
163 }
164 }

◆ getAngle()

static double JGEOMETRY3D::JOmega3D::getAngle ( const size_t N)
inlinestaticinherited

Get approximate angular spacing given number of directions.

Parameters
Nnumber of directions
Returns
angle [rad]

Definition at line 173 of file JOmega3D.hh.

174 {
175 if (N != 0)
176 return 10.0 * sqrt((double) 240 / (double) N) * PI / 180.0;
177 else
178 return PI;
179 }

◆ find()

int JGEOMETRY3D::JOmega3D_t::find ( const JAngle3D & dir) const
inlineinherited

Get index of direction closest to given direction.

Parameters
dirdirection
Returns
index (-1 if error)

Definition at line 41 of file JOmega3D.hh.

42 {
43 double dot = -1.0;
44 int index = -1;
45
46 for (const_iterator i = this->begin(); i != this->end(); ++i) {
47
48 const double x = dir.getDot(*i);
49
50 if (x > dot) {
51 dot = x;
52 index = std::distance(this->begin(), i);
53 }
54 }
55
56 return index;
57 }

Member Data Documentation

◆ __theta

double JGEOMETRY3D::JAngle3D::__theta
protectedinherited

Definition at line 326 of file JAngle3D.hh.

◆ __phi

double JGEOMETRY3D::JAngle3D::__phi
protectedinherited

Definition at line 327 of file JAngle3D.hh.


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