summaryrefslogtreecommitdiff
path: root/src/main/StraightElement.h
blob: 5a1d944b69d4befcb291a3e792a0d0d805348c97 (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
/*
 * StraightElement.h
 *
 *  Created on: Mar 22, 2011
 *      Author: jakob
 */

#ifndef STRAIGHTELEMENT_H_
#define STRAIGHTELEMENT_H_

#include "Vector3D.h"
#include "Element.h"
#include "Particle.h"

namespace vhc {


class StraightElement: public Element {

public:

	StraightElement(const Vector3D& entry, const Vector3D& exit, double sectionRadius, Element* next = NULL):
		Element(entry, exit, sectionRadius, next)
	{};

	//TODO ! why can't you access protected variables, i.e. entryPosition won't work?!
	virtual bool isOutside(const Particle& particle) const {
		Vector3D a(particle.getPosition() - entryPosition);
		const Vector3D b = (particle.getPosition() - entryPosition);
		return (a.cross(b)).norm() / getDiagonal().norm() > sectionRadius;
	};

	virtual bool isPast(const Particle& particle) const {
		const Vector3D v(particle.getPosition() - entryPosition);
		return getDiagonal().dot(v) > getDiagonal().dot(getDiagonal());
	}

};

}

#endif /* STRAIGHTELEMENT_H_ */