summaryrefslogtreecommitdiff
path: root/src/main/Dipole.cc
blob: a313d12d44f7677e112af174b90812fdbed11d6e (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
/*
 * Dipole.cc
 *
 *  Created on: Mar 28, 2011
 *      Author: jakob
 */

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

namespace vhc {

Dipole::Dipole(const Vector3D& entry, const Vector3D& exit, double sectionRadius, double curvature, const Vector3D& magneticField, Element* next):
		CurvedElement(entry, exit, sectionRadius, curvature, next),
				  _magneticField(magneticField) {

}

Dipole::~Dipole() {}

Vector3D Dipole::getMagneticField() const {return _magneticField;}

void Dipole::setMagneticField(const Vector3D& field) {_magneticField = field;}

Vector3D Dipole::magneticFieldAt(const Vector3D& position) const {return _magneticField;}

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

std::string Dipole::toString() const {
	std::stringstream s;
	s << CurvedElement::toString() << "\n";
	s << "\tB: " << getMagneticField();
	s << "\t|B|: " << getMagneticField().norm();
	return s.str();
}

void Dipole::accept(const ElementVisitor& v) const {v.visit(this);}

Dipole* Dipole::clone() const {
	return new Dipole(getEntryPosition(), getExitPosition(), getSectionRadius(), getCurvature(), _magneticField);
}

} //vhc