summaryrefslogtreecommitdiff
path: root/src/main/CurvedElement.h
blob: 88f33b6308228468242d859a52e3e6d89246c60f (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 <cmath.h>
#include "Element.h"
#include "Particle.h"
#include "Vector3D.h"

namespace vhc {

//TODO implement abstract methods of Element
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 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_ */