summaryrefslogtreecommitdiff
path: root/src/main/Element.cc
blob: 25efa8c106cb1f56d804b0790dac839aef976c59 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * Element.cc
 *
 *  Created on: Mar 16, 2011
 *      Author: jakob
 */


#include <sstream>
#include "Element.h"

namespace vhc {

Element::Element(const Vector3D& entry, const Vector3D& exit, double sectionRadius, Element* next):
		entryPosition(entry),
		exitPosition(exit),
		sectionRadius(sectionRadius),
		previous(NULL),
		next(next)
		{}

Element::~Element() {};

bool Element::isAfter(const Particle& particle) const {return isAfter(particle.getPosition());}

bool Element::isBefore(const Particle& particle) const {return isBefore(particle.getPosition());}

bool Element::isBeside(const Particle& particle) const {return isBeside(particle.getPosition());}

bool Element::contains(const Vector3D& position) const {
	return !(isAfter(position) || isBefore(position) || isBeside(position));
}

bool Element::contains(const Particle& particle) const {
	return contains(particle.getPosition());
}

Vector3D Element::magneticFieldAt(const Vector3D& position) const {return Vector3D::Null;}

Vector3D Element::electricFieldAt(const Vector3D& position) const {return Vector3D::Null;}

Vector3D Element::getDiagonal() const {return exitPosition - entryPosition;}

Vector3D Element::getEntryPosition() const {return entryPosition;}

Vector3D Element::getExitPosition() const {return exitPosition;}

double Element::getSectionRadius() const {return sectionRadius;}

Element* const Element::getPrevious() const {return previous;}

void Element::setPrevious(Element* p) {previous = p;}

Element* const Element::getNext() const {return next;}

void Element::setNext(Element* n) {next = n;}

bool Element::isConnected() const {return next != NULL;}

std::string Element::getType() const {return "Element";}

std::string Element::toString() const {
	std::stringstream s;
	s << getType() << ":\n";
	s << "\tentry: " << getEntryPosition()	<<	"\n";
	s << "\texit: " << getExitPosition()	<<	"\n";
	s << "\tsection radius: " << getSectionRadius()	<<	"\n";
	s << "\tconnected: " << (isConnected() ? "true" : "false");
	return s.str();
}

} //vhc