Geant4-11
Public Member Functions | Private Attributes
G4VViewer::G4Spline Class Reference

#include <G4VViewer.hh>

Public Member Functions

void AddSplinePoint (const G4Vector3D &v)
 
G4Vector3D CatmullRom_Eq (float t, const G4Vector3D &p1, const G4Vector3D &p2, const G4Vector3D &p3, const G4Vector3D &p4)
 
 G4Spline ()
 
G4Vector3D GetInterpolatedSplinePoint (float t)
 
int GetNumPoints ()
 
G4Vector3D GetPoint (int)
 
 ~G4Spline ()
 

Private Attributes

float delta_t
 
std::vector< G4Vector3Dvp
 

Detailed Description

Definition at line 190 of file G4VViewer.hh.

Constructor & Destructor Documentation

◆ G4Spline()

G4VViewer::G4Spline::G4Spline ( )

Definition at line 402 of file G4VViewer.cc.

403: vp(), delta_t(0)
404{
405}
std::vector< G4Vector3D > vp
Definition: G4VViewer.hh:209

◆ ~G4Spline()

G4VViewer::G4Spline::~G4Spline ( )

Definition at line 408 of file G4VViewer.cc.

409{}

Member Function Documentation

◆ AddSplinePoint()

void G4VViewer::G4Spline::AddSplinePoint ( const G4Vector3D v)

Definition at line 425 of file G4VViewer.cc.

426{
427 vp.push_back(v);
428 delta_t = (float)1 / (float)vp.size();
429}

Referenced by G4VViewer::ComputeFlyThrough().

◆ CatmullRom_Eq()

G4Vector3D G4VViewer::G4Spline::CatmullRom_Eq ( float  t,
const G4Vector3D p1,
const G4Vector3D p2,
const G4Vector3D p3,
const G4Vector3D p4 
)

Definition at line 412 of file G4VViewer.cc.

413{
414 float t2 = t * t;
415 float t3 = t2 * t;
416
417 float b1 = .5 * ( -t3 + 2*t2 - t);
418 float b2 = .5 * ( 3*t3 - 5*t2 + 2);
419 float b3 = .5 * (-3*t3 + 4*t2 + t);
420 float b4 = .5 * ( t3 - t2 );
421
422 return (p1*b1 + p2*b2 + p3*b3 + p4*b4);
423}

◆ GetInterpolatedSplinePoint()

G4Vector3D G4VViewer::G4Spline::GetInterpolatedSplinePoint ( float  t)

Definition at line 442 of file G4VViewer.cc.

443{
444 // Find out in which interval we are on the spline
445 int p = (int)(t / delta_t);
446 // Compute local control point indices
447#define BOUNDS(pp) { if (pp < 0) pp = 0; else if (pp >= (int)vp.size()-1) pp = vp.size() - 1; }
448 int p0 = p - 1; BOUNDS(p0);
449 int p1 = p; BOUNDS(p1);
450 int p2 = p + 1; BOUNDS(p2);
451 int p3 = p + 2; BOUNDS(p3);
452 // Relative (local) time
453 float lt = (t - delta_t*(float)p) / delta_t;
454 // Interpolate
455 return CatmullRom_Eq(lt, vp[p0], vp[p1], vp[p2], vp[p3]);
456}
#define BOUNDS(pp)
G4Vector3D CatmullRom_Eq(float t, const G4Vector3D &p1, const G4Vector3D &p2, const G4Vector3D &p3, const G4Vector3D &p4)
Definition: G4VViewer.cc:412

References BOUNDS.

Referenced by G4VViewer::ComputeFlyThrough().

◆ GetNumPoints()

int G4VViewer::G4Spline::GetNumPoints ( )

Definition at line 437 of file G4VViewer.cc.

438{
439 return vp.size();
440}

◆ GetPoint()

G4Vector3D G4VViewer::G4Spline::GetPoint ( int  a)

Definition at line 432 of file G4VViewer.cc.

433{
434 return vp[a];
435}

Field Documentation

◆ delta_t

float G4VViewer::G4Spline::delta_t
private

Definition at line 210 of file G4VViewer.hh.

◆ vp

std::vector<G4Vector3D> G4VViewer::G4Spline::vp
private

Definition at line 209 of file G4VViewer.hh.


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