DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Unit3Vec Class Reference

#include <DLG4Units.hh>

Collaboration diagram for Unit3Vec:
[legend]

Public Member Functions

 Unit3Vec ()=default
 
 Unit3Vec (const Unit3Vec &other)
 
Unit3Vecoperator= (const Unit3Vec &other)
 
 Unit3Vec (double x, double y, double z, const Length &u)
 
 Unit3Vec (const G4ThreeVector &v, const Length &u)
 
Unit3Vec FromNative (const G4ThreeVector &v)
 
Length x () const
 
Length y () const
 
Length z () const
 
void x (const Length &val)
 
void y (const Length &val)
 
void z (const Length &val)
 
 Unit3Vec (const Length &x, const Length &y, const Length &z)
 
G4ThreeVector InUnits () const
 
G4ThreeVector InUnits (const Length &u) const
 
G4ThreeVector Native () const
 

Protected Attributes

std::optional< G4ThreeVector > NativeVec_
 
Length default_length_
 

Detailed Description

A 3 vector that is scalable with/to Units.

Definition at line 452 of file DLG4Units.hh.

Constructor & Destructor Documentation

◆ Unit3Vec() [1/5]

Unit3Vec ( )
default

◆ Unit3Vec() [2/5]

Unit3Vec ( const Unit3Vec other)
inline

Definition at line 456 of file DLG4Units.hh.

457 : NativeVec_(other.NativeVec_),
458 default_length_(other.default_length_) {
459 }
std::optional< G4ThreeVector > NativeVec_
Definition DLG4Units.hh:516

◆ Unit3Vec() [3/5]

Unit3Vec ( double  x,
double  y,
double  z,
const Length u 
)
inline

Definition at line 471 of file DLG4Units.hh.

471 {
472 NativeVec_ = G4ThreeVector(x, y, z) * u.Native;
473 }
Length x() const
Definition DLG4Units.hh:484
Length y() const
Definition DLG4Units.hh:485
Length z() const
Definition DLG4Units.hh:486

◆ Unit3Vec() [4/5]

Unit3Vec ( const G4ThreeVector &  v,
const Length u 
)
inline

Definition at line 475 of file DLG4Units.hh.

475 {
476 NativeVec_ = v * u.Native;
477 }

◆ Unit3Vec() [5/5]

Unit3Vec ( const Length x,
const Length y,
const Length z 
)
inline

Definition at line 492 of file DLG4Units.hh.

492 {
493 NativeVec_ = G4ThreeVector(x.Native, y.Native, z.Native);
494 }
PropertySetter Native
Definition DLG4Units.hh:182

Member Function Documentation

◆ FromNative()

Unit3Vec FromNative ( const G4ThreeVector &  v)
inline

Definition at line 479 of file DLG4Units.hh.

479 {
480 return Unit3Vec(v, Length::native);
481 }

◆ InUnits() [1/2]

G4ThreeVector InUnits ( ) const
inline

Definition at line 496 of file DLG4Units.hh.

496{ return InUnits(default_length_); }
G4ThreeVector InUnits() const
Definition DLG4Units.hh:496

◆ InUnits() [2/2]

G4ThreeVector InUnits ( const Length u) const
inline

Definition at line 498 of file DLG4Units.hh.

498 {
499 if (!NativeVec_.has_value()) {
500 G4Exception("Unit3Vec::InUnits", "Uninitialized", FatalException,
501 "Attempted to read Unit3Vec before setting it.");
502 }
503 return (*NativeVec_) / u.Native;
504 }

◆ Native()

G4ThreeVector Native ( ) const
inline

Definition at line 507 of file DLG4Units.hh.

507 {
508 if (!NativeVec_.has_value()) {
509 G4Exception("Unit3Vec::GetRaw", "Uninitialized", FatalException,
510 "Attempted to read Unit3Vec before setting it.");
511 }
512 return *NativeVec_;
513 }

◆ operator=()

Unit3Vec & operator= ( const Unit3Vec other)
inline

Definition at line 463 of file DLG4Units.hh.

463 {
464 if (this != &other) {
465 NativeVec_ = other.NativeVec_;
466 default_length_ = other.default_length_;
467 }
468 return *this;
469 }

◆ x() [1/2]

Length x ( ) const
inline

Definition at line 484 of file DLG4Units.hh.

484{ return Length::FromNative(Native().x()); }
G4ThreeVector Native() const
Definition DLG4Units.hh:507
static Length FromNative(G4double)
Definition DLG4Units.hh:253

◆ x() [2/2]

void x ( const Length val)
inline

Definition at line 488 of file DLG4Units.hh.

488{ EnsureInternalVec().setX(val.Native); }

◆ y() [1/2]

Length y ( ) const
inline

Definition at line 485 of file DLG4Units.hh.

485{ return Length::FromNative(Native().y()); }

◆ y() [2/2]

void y ( const Length val)
inline

Definition at line 489 of file DLG4Units.hh.

489{ EnsureInternalVec().setY(val.Native); }

◆ z() [1/2]

Length z ( ) const
inline

Definition at line 486 of file DLG4Units.hh.

486{ return Length::FromNative(Native().z()); }

◆ z() [2/2]

void z ( const Length val)
inline

Definition at line 490 of file DLG4Units.hh.

490{ EnsureInternalVec().setZ(val.Native); }

Member Data Documentation

◆ default_length_

Length default_length_
protected

Definition at line 517 of file DLG4Units.hh.

◆ NativeVec_

std::optional<G4ThreeVector> NativeVec_
protected

Definition at line 516 of file DLG4Units.hh.


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