summaryrefslogtreecommitdiff
path: root/src/main/StraightElement.h
blob: eb493d080ad9857947dbb10f503c59162a796d99 (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
46
47
48
49
50
51
52
53
54
55
/*
 * StraightElement.h
 *
 *  Created on: Mar 22, 2011
 *      Author: jakob
 */

#ifndef STRAIGHTELEMENT_H_
#define STRAIGHTELEMENT_H_

#include "Vector3D.h"
#include "Element.h"
#include "Particle.h"
#include "ElementVisitor.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)
	{};

	virtual ~StraightElement() {};

	//virtual StraightElement* copy() const {return new StraightElement(*this);}

	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());
	}

	virtual std::string getType() const {return "Straight Element";}
	virtual std::string toString() const {
		std::stringstream s;
		s << Element::toString();
		return s.str();
	}

	virtual void accept(ElementVisitor& v) {v.visit(this);}

};

}

#endif /* STRAIGHTELEMENT_H_ */