Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VViewer::G4Spline Class Reference

#include <G4VViewer.hh>

Public Member Functions

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

Detailed Description

Definition at line 190 of file G4VViewer.hh.

Constructor & Destructor Documentation

◆ G4Spline()

G4VViewer::G4Spline::G4Spline ( )

Definition at line 392 of file G4VViewer.cc.

393: vp(), delta_t(0)
394{
395}

◆ ~G4Spline()

G4VViewer::G4Spline::~G4Spline ( )

Definition at line 398 of file G4VViewer.cc.

399{}

Member Function Documentation

◆ AddSplinePoint()

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

Definition at line 415 of file G4VViewer.cc.

416{
417 vp.push_back(v);
418 delta_t = (float)1 / (float)vp.size();
419}

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 402 of file G4VViewer.cc.

403{
404 float t2 = t * t;
405 float t3 = t2 * t;
406
407 float b1 = .5 * ( -t3 + 2*t2 - t);
408 float b2 = .5 * ( 3*t3 - 5*t2 + 2);
409 float b3 = .5 * (-3*t3 + 4*t2 + t);
410 float b4 = .5 * ( t3 - t2 );
411
412 return (p1*b1 + p2*b2 + p3*b3 + p4*b4);
413}

◆ GetInterpolatedSplinePoint()

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

Definition at line 432 of file G4VViewer.cc.

433{
434 // Find out in which interval we are on the spline
435 int p = (int)(t / delta_t);
436 // Compute local control point indices
437#define BOUNDS(pp) { if (pp < 0) pp = 0; else if (pp >= (int)vp.size()-1) pp = vp.size() - 1; }
438 int p0 = p - 1; BOUNDS(p0);
439 int p1 = p; BOUNDS(p1);
440 int p2 = p + 1; BOUNDS(p2);
441 int p3 = p + 2; BOUNDS(p3);
442 // Relative (local) time
443 float lt = (t - delta_t*(float)p) / delta_t;
444 // Interpolate
445 return CatmullRom_Eq(lt, vp[p0], vp[p1], vp[p2], vp[p3]);
446}
#define BOUNDS(pp)
G4Vector3D CatmullRom_Eq(float t, const G4Vector3D &p1, const G4Vector3D &p2, const G4Vector3D &p3, const G4Vector3D &p4)
Definition: G4VViewer.cc:402

Referenced by G4VViewer::ComputeFlyThrough().

◆ GetNumPoints()

int G4VViewer::G4Spline::GetNumPoints ( )

Definition at line 427 of file G4VViewer.cc.

428{
429 return vp.size();
430}

◆ GetPoint()

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

Definition at line 422 of file G4VViewer.cc.

423{
424 return vp[a];
425}

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