Public Member Functions | Private Member Functions | List of all members
mag::Interpolator Class Reference

#include <GArMagneticField.h>

Public Member Functions

 Interpolator ()
 
float interpolate (const float *point, const std::vector< std::vector< std::vector< float >>> &g, const float *delta, const float *offset) const
 
float interpolate (float x, float y, float z, const std::vector< std::vector< std::vector< float >>> &g, float hx, float hy, float hz, float xo, float yo, float zo) const
 

Private Member Functions

float conv_kernel (float s) const
 

Detailed Description

Definition at line 67 of file GArMagneticField.h.

Constructor & Destructor Documentation

mag::Interpolator::Interpolator ( )

Definition at line 464 of file GArMagneticField.cxx.

464 {}

Member Function Documentation

float mag::Interpolator::conv_kernel ( float  s) const
private

Definition at line 518 of file GArMagneticField.cxx.

519 {
520  float v = 0;
521  float z = std::abs(s);
522 
523  if(0 <= z && z < 1)
524  v = 1 + (0.5) * z * z * (3 * z - 5);
525 
526  else if(1 < z && z < 2)
527  v = 2 - z * (4 + 0.5 * z * (z - 5));
528 
529  return v;
530 }
T abs(T value)
static QCString * s
Definition: config.cpp:1042
float mag::Interpolator::interpolate ( const float *  point,
const std::vector< std::vector< std::vector< float >>> &  g,
const float *  delta,
const float *  offset 
) const

Definition at line 467 of file GArMagneticField.cxx.

470 {
471  return interpolate(point[0], point[1], point[2], g, delta[0], delta[1], delta[2], offset[0],
472  offset[1], offset[2]);
473 }
float interpolate(const float *point, const std::vector< std::vector< std::vector< float >>> &g, const float *delta, const float *offset) const
float mag::Interpolator::interpolate ( float  x,
float  y,
float  z,
const std::vector< std::vector< std::vector< float >>> &  g,
float  hx,
float  hy,
float  hz,
float  xo,
float  yo,
float  zo 
) const

Definition at line 476 of file GArMagneticField.cxx.

479 {
480  float v = 0;
481 
482  const int xsize = g.size();
483  const int ysize = g[0].size();
484  const int zsize = g[0][0].size();
485 
486  const float xp = (x - xo) / hx;
487  const float yp = (y - yo) / hy;
488  const float zp = (z - zo) / hz;
489 
490  const int x_idx = std::floor(xp);
491  const int y_idx = std::floor(yp);
492  const int z_idx = std::floor(zp);
493 
494  for(auto i : {x_idx - 1, x_idx, x_idx + 1, x_idx + 2})
495  {
496  for(auto j : {y_idx - 1, y_idx, y_idx + 1, y_idx + 2})
497  {
498  for(auto k : {z_idx - 1, z_idx, z_idx + 1, z_idx + 2})
499  {
500  if(i < 0 || j < 0 || k < 0)
501  continue;
502 
503  if(i >= xsize || j >= ysize || k >= zsize)
504  continue;
505 
506  const float x_c = conv_kernel(xp - i);
507  const float y_c = conv_kernel(yp - j);
508  const float z_c = conv_kernel(zp - k);
509  v += g[i][j][k] * x_c * y_c * z_c;
510  }
511  }
512  }
513 
514  return v;
515 }
float conv_kernel(float s) const
list x
Definition: train.py:276

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