LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
trkf::BezierCurveHelper Class Reference

#include "BezierCurveHelper.h"

Public Member Functions

 BezierCurveHelper ()
 
 BezierCurveHelper (int fCurveRes)
 
 ~BezierCurveHelper ()
 
void reconfigure (const fhicl::ParameterSet &pset)
 
std::vector< TVector3 > GetBezierPoints (recob::Seed const &s1, recob::Seed const &s2, int N=100)
 
std::vector< TVector3 > GetBezierPointsQuartic (recob::Seed const &s1, recob::Seed const &s2, int N=100)
 
std::vector< TVector3 > GetBezierPointsCubic (recob::Seed const &s1, recob::Seed const &s2, int N=100)
 
double GetSegmentLength (recob::Seed const &s1, recob::Seed const &s2)
 
void GetBezierPointXYZ (recob::Seed const &s1, recob::Seed const &s2, float t, double *xyz)
 
TVector3 GetBezierPoint (recob::Seed const &s1, recob::Seed const &s2, float t)
 
TVector3 GetBezierPointCubic (recob::Seed const &s1, recob::Seed const &s2, float t)
 
TVector3 GetBezierPointQuartic (recob::Seed const &s1, recob::Seed const &s2, float t)
 
void GetDirectionScales (double *Pt1, double *Pt2, double *Dir1, double *Dir2, double *Scales)
 
void SetCurveResolution (int CurveRes)
 
int GetCurveResolution ()
 

Private Attributes

int fCurveResolution
 

Detailed Description

Definition at line 29 of file BezierCurveHelper.h.

Constructor & Destructor Documentation

trkf::BezierCurveHelper::BezierCurveHelper ( )

Definition at line 32 of file BezierCurveHelper.cxx.

References fCurveResolution.

33 {
34  fCurveResolution=100;
35 }
trkf::BezierCurveHelper::BezierCurveHelper ( int  fCurveRes)
explicit

Definition at line 37 of file BezierCurveHelper.cxx.

References fCurveResolution.

38 {
39  fCurveResolution=CurveRes;
40 }
trkf::BezierCurveHelper::~BezierCurveHelper ( )

Definition at line 45 of file BezierCurveHelper.cxx.

46 {
47 }

Member Function Documentation

TVector3 trkf::BezierCurveHelper::GetBezierPoint ( recob::Seed const &  s1,
recob::Seed const &  s2,
float  t 
)

Definition at line 122 of file BezierCurveHelper.cxx.

References GetBezierPointCubic().

Referenced by GetBezierPointXYZ().

123 {
124  return GetBezierPointCubic(s1, s2, s);
125 }
Float_t s
Definition: plot.C:23
TVector3 GetBezierPointCubic(recob::Seed const &s1, recob::Seed const &s2, float t)
TVector3 trkf::BezierCurveHelper::GetBezierPointCubic ( recob::Seed const &  s1,
recob::Seed const &  s2,
float  t 
)

Definition at line 181 of file BezierCurveHelper.cxx.

References recob::Seed::GetDirection(), GetDirectionScales(), recob::Seed::GetPoint(), and s.

Referenced by GetBezierPoint().

182 {
183  TVector3 ReturnVec3;
184 
185  double Pt1[3], Pt2[3], Dir1[3], Dir2[3], Mid1[3], Mid2[3], Dummy[3];
186  s1.GetDirection(Dir1, Dummy);
187  s2.GetDirection(Dir2, Dummy);
188  s1.GetPoint(Pt1, Dummy);
189  s2.GetPoint(Pt2, Dummy);
190 
191  if(s<=0.) return TVector3(Pt1[0],Pt1[1],Pt1[2]);
192  if(s>=1.) return TVector3(Pt2[0],Pt2[1],Pt2[2]);
193 
194 
195  double DirScales[2];
196  GetDirectionScales(Pt1,Pt2,Dir1,Dir2,DirScales);
197 
198  double ns=1.-s;
199  for(int i=0; i!=3; i++)
200  {
201  Mid1[i]=Pt1[i]+Dir1[i]*DirScales[0];
202  Mid2[i]=Pt2[i]+Dir2[i]*DirScales[1];
203  ReturnVec3[i]=
204  ns * ns * ns * Pt1[i]
205  + 3.* ns * ns * s * Mid1[i]
206  + 3.* ns * s * s * Mid2[i]
207  + s * s * s * Pt2[i];
208  }
209 
210 
211  return ReturnVec3;
212 
213 
214 
215 }
Float_t s
Definition: plot.C:23
void GetDirectionScales(double *Pt1, double *Pt2, double *Dir1, double *Dir2, double *Scales)
TVector3 trkf::BezierCurveHelper::GetBezierPointQuartic ( recob::Seed const &  s1,
recob::Seed const &  s2,
float  t 
)

Definition at line 130 of file BezierCurveHelper.cxx.

References recob::Seed::GetDirection(), recob::Seed::GetPoint(), and s.

131 {
132  TVector3 ReturnVec3;
133 
134  double Pt1[3], Pt2[3], Dir1[3], Dir2[3], Mid1[3], Mid2[3], Mid3[3], Dummy[3];
135  s1.GetDirection(Dir1, Dummy);
136  s2.GetDirection(Dir2, Dummy);
137  s1.GetPoint(Pt1, Dummy);
138  s2.GetPoint(Pt2, Dummy);
139 
140  if(s<=0.) return TVector3(Pt1[0],Pt1[1],Pt1[2]);
141  if(s>=1.) return TVector3(Pt2[0],Pt2[1],Pt2[2]);
142 
143  TVector3 pt1(Pt1[0],Pt1[1],Pt1[2]);
144  TVector3 pt2(Pt2[0],Pt2[1],Pt2[2]);
145  TVector3 dir1(Dir1[0],Dir1[1],Dir1[2]);
146  TVector3 dir2(Dir2[0],Dir2[1],Dir2[2]);
147 
148  double lambda1 = (pt1-pt2).Dot(dir1-dir2)/(pow(dir2.Dot(dir1),2)-dir2.Mag2()*dir1.Mag2());
149  double lambda2 = (pt2-pt1).Dot(dir2-dir1)/(pow(dir1.Dot(dir2),2)-dir1.Mag2()*dir2.Mag2());
150 
151 
152  int Sign1, Sign2;
153 
154  if(lambda1>0) Sign1=1;
155  else Sign1=-1;
156 
157  if(lambda2>0) Sign2=1;
158  else Sign2=-1;
159 
160  double ns=1.-s;
161  for(int i=0; i!=3; i++)
162  {
163  Mid1[i]=Pt1[i] + Sign1*Dir1[i];
164  Mid2[i]=0.5*(Pt1[i] + lambda1 * Dir1[i] + Pt2[i] +lambda2 * Dir2[i]);
165  Mid3[i]=Pt2[i] - Sign2*Dir2[i];
166  ReturnVec3[i]=
167  ns*ns*ns*ns * Pt1[i]
168  + 4.*ns*ns*ns*s * Mid1[i]
169  + 6.*ns*ns*s*s * Mid2[i]
170  + 4.*ns*s*s*s * Mid3[i]
171  + s*s*s*s * Pt2[i];
172  }
173 
174  return ReturnVec3;
175 
176 }
Float_t s
Definition: plot.C:23
std::vector< TVector3 > trkf::BezierCurveHelper::GetBezierPoints ( recob::Seed const &  s1,
recob::Seed const &  s2,
int  N = 100 
)

Definition at line 225 of file BezierCurveHelper.cxx.

References GetBezierPointsCubic().

Referenced by trkf::BezierTrackerAlgorithm::EvaluateOccupancy(), and GetSegmentLength().

226 {
227  return GetBezierPointsCubic(s1, s2, N);
228 }
std::vector< TVector3 > GetBezierPointsCubic(recob::Seed const &s1, recob::Seed const &s2, int N=100)
std::vector< TVector3 > trkf::BezierCurveHelper::GetBezierPointsCubic ( recob::Seed const &  s1,
recob::Seed const &  s2,
int  N = 100 
)

Definition at line 233 of file BezierCurveHelper.cxx.

References recob::Seed::GetDirection(), GetDirectionScales(), and recob::Seed::GetPoint().

Referenced by GetBezierPoints().

234 {
235 
236  std::vector<TVector3> ReturnVec;
237  ReturnVec.resize(N);
238 
239  double Pt1[3], Pt2[3], Dir1[3], Dir2[3], Mid1[3], Mid2[3], Dummy[3];
240  s1.GetDirection(Dir1, Dummy);
241  s2.GetDirection(Dir2, Dummy);
242  s1.GetPoint(Pt1, Dummy);
243  s2.GetPoint(Pt2, Dummy);
244 
245  double DirScales[2];
246  GetDirectionScales(Pt1,Pt2,Dir1,Dir2,DirScales);
247 
248 
249  for(int i=0; i!=3; i++)
250  {
251  Mid1[i]=Pt1[i]+Dir1[i]*DirScales[0];
252  Mid2[i]=Pt2[i]+Dir2[i]*DirScales[1];
253  for(int p=0; p!=N; p++)
254  {
255  double t = float(p) / float(N-1);
256  double nt = 1.-t;
257  ReturnVec.at(p)[i] =
258  nt*nt*nt * Pt1[i]
259  + 3.*nt*nt*t * Mid1[i]
260  + 3.*nt*t*t * Mid2[i]
261  + t*t*t * Pt2[i];
262  }
263  }
264 
265  return ReturnVec;
266 }
void GetDirectionScales(double *Pt1, double *Pt2, double *Dir1, double *Dir2, double *Scales)
std::vector< TVector3 > trkf::BezierCurveHelper::GetBezierPointsQuartic ( recob::Seed const &  s1,
recob::Seed const &  s2,
int  N = 100 
)

Definition at line 271 of file BezierCurveHelper.cxx.

References recob::Seed::GetDirection(), and recob::Seed::GetPoint().

272 {
273 
274  std::vector<TVector3> ReturnVec;
275  ReturnVec.resize(N);
276 
277  double Pt1[3], Pt2[3], Dir1[3], Dir2[3], Mid1[3], Mid2[3], Mid3[3], Dummy[3];
278  s1.GetDirection(Dir1, Dummy);
279  s2.GetDirection(Dir2, Dummy);
280  s1.GetPoint(Pt1, Dummy);
281  s2.GetPoint(Pt2, Dummy);
282 
283  TVector3 pt1(Pt1[0],Pt1[1],Pt1[2]);
284  TVector3 pt2(Pt2[0],Pt2[1],Pt2[2]);
285  TVector3 dir1(Dir1[0],Dir1[1],Dir1[2]);
286  TVector3 dir2(Dir2[0],Dir2[1],Dir2[2]);
287 
288 
289  double lambda1 = (pt1-pt2).Dot(dir1-dir2)/(pow(dir2.Dot(dir1),2)-dir2.Mag2()*dir1.Mag2());
290  double lambda2 = (pt2-pt1).Dot(dir2-dir1)/(pow(dir1.Dot(dir2),2)-dir1.Mag2()*dir2.Mag2());
291 
292  int Sign1, Sign2;
293 
294  if(lambda1>0) Sign1=1;
295  else Sign1=-1;
296 
297  if(lambda2>0) Sign2=1;
298  else Sign2=-1;
299 
300  for(int i=0; i!=3; i++)
301  {
302 
303 
304  Mid1[i]=Pt1[i] + Sign1*Dir1[i];
305  Mid2[i]=0.5*(Pt1[i] + lambda1 * Dir1[i] + Pt2[i] +lambda2 * Dir2[i]);
306  Mid3[i]=Pt2[i] - Sign2*Dir2[i];
307  for(int p=0; p!=N; p++)
308  {
309  double t = float(p) / float(N-1);
310  double nt = 1.-t;
311  ReturnVec.at(p)[i] =
312  nt*nt*nt*nt * Pt1[i]
313  + 4.*nt*nt*nt*t * Mid1[i]
314  + 6.*nt*nt*t*t * Mid2[i]
315  + 4.*nt*t*t*t * Mid3[i]
316  + t*t*t*t * Pt2[i];
317 
318  }
319  }
320 
321  return ReturnVec;
322 }
void trkf::BezierCurveHelper::GetBezierPointXYZ ( recob::Seed const &  s1,
recob::Seed const &  s2,
float  t,
double *  xyz 
)

Definition at line 108 of file BezierCurveHelper.cxx.

References GetBezierPoint().

Referenced by trkf::BezierTrack::GetTrackPoint().

109 {
110  TVector3 BezierPoint = GetBezierPoint(s1, s2, s);
111  xyz[0]=BezierPoint[0];
112  xyz[1]=BezierPoint[1];
113  xyz[2]=BezierPoint[2];
114 
115 }
Float_t s
Definition: plot.C:23
TVector3 GetBezierPoint(recob::Seed const &s1, recob::Seed const &s2, float t)
int trkf::BezierCurveHelper::GetCurveResolution ( )
inline

Definition at line 54 of file BezierCurveHelper.h.

References fCurveResolution.

void trkf::BezierCurveHelper::GetDirectionScales ( double *  Pt1,
double *  Pt2,
double *  Dir1,
double *  Dir2,
double *  Scales 
)

Definition at line 72 of file BezierCurveHelper.cxx.

Referenced by GetBezierPointCubic(), and GetBezierPointsCubic().

73 {
74 
75  double PtSepVec[3];
76  for(int i=0; i!=3; ++i) PtSepVec[i]=Pt2[i]-Pt1[i];
77 
78  double PtSep = pow(
79  pow(PtSepVec[0],2) +
80  pow(PtSepVec[1],2) +
81  pow(PtSepVec[2],2),0.5);
82 
83  double Dir1Length = pow(Dir1[0]*Dir1[0]+
84  Dir1[1]*Dir1[1]+
85  Dir1[2]*Dir1[2],0.5);
86 
87  double Dir2Length = pow(Dir2[0]*Dir2[0]+
88  Dir2[1]*Dir2[1]+
89  Dir2[2]*Dir2[2],0.5);
90 
91  if((PtSepVec[0]*Dir1[0]+PtSepVec[1]*Dir1[1]+PtSepVec[2]*Dir1[2])>0)
92  Scales[0] = PtSep / (3.*Dir1Length);
93  else
94  Scales[0] = 0 - PtSep / (3.*Dir1Length);
95 
96  if((PtSepVec[0]*Dir2[0]+PtSepVec[1]*Dir2[1]+PtSepVec[2]*Dir2[2])>0)
97  Scales[1] = 0 - PtSep / (3.*Dir2Length);
98  else
99  Scales[1] = PtSep / (3.*Dir2Length);
100 
101 }
double trkf::BezierCurveHelper::GetSegmentLength ( recob::Seed const &  s1,
recob::Seed const &  s2 
)

Definition at line 55 of file BezierCurveHelper.cxx.

References fCurveResolution, and GetBezierPoints().

Referenced by trkf::BezierTrack::CalculateSegments().

56 {
57  double Length=0;
58  std::vector<TVector3> BezierPoints = GetBezierPoints(s1, s2, fCurveResolution);
59  for(unsigned int p=0; p!=BezierPoints.size()-1; ++p)
60  {
61  Length+=(BezierPoints.at(p+1)-BezierPoints.at(p)).Mag();
62  }
63  return Length;
64 }
std::vector< TVector3 > GetBezierPoints(recob::Seed const &s1, recob::Seed const &s2, int N=100)
void trkf::BezierCurveHelper::reconfigure ( const fhicl::ParameterSet pset)
void trkf::BezierCurveHelper::SetCurveResolution ( int  CurveRes)
inline

Definition at line 53 of file BezierCurveHelper.h.

References fCurveResolution.

Member Data Documentation

int trkf::BezierCurveHelper::fCurveResolution
private

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