blob: 10fd2e571157aa3db767af0b687eaa68f2aa5cd4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/*
* CurvedElement.h
*
* Created on: Mar 22, 2011
* Author: jakob
*/
#ifndef CURVEDELEMENT_H_
#define CURVEDELEMENT_H_
#include <math.h>
#include "Element.h"
#include "Particle.h"
#include "Vector3D.h"
namespace vhc {
class CurvedElement: public Element {
protected:
Vector3D curvatureCenter;
double curvature;
public:
CurvedElement(const Vector3D& entry, const Vector3D& exit, double sectionRadius, double curvature, Element* next = NULL);
virtual CurvedElement* copy() const {return new CurvedElement(*this);}
virtual bool isOutside(const Particle& particle) const {
Vector3D x(particle.getPosition() - entryPosition);
return (x - Vector3D(x.getX(), x.getY(), 0).unit() / fabs(curvature)).norm() > sectionRadius;
}
virtual bool isPast(const Particle& particle) const {
Vector3D out = (entryPosition - curvatureCenter).cross(exitPosition - curvatureCenter).cross(entryPosition - curvatureCenter);
return (particle.getPosition() - exitPosition).dot(out) > 0;
}
};
}
#endif /* CURVEDELEMENT_H_ */
|