blob: ab73a716ae569fbfc799557b0341190c66ed1329 (
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
|
/*
* StraightElement.cc
*
* Created on: Mar 22, 2011
* Author: jakob
*/
#include "StraightElement.h"
namespace vhc {
StraightElement::StraightElement(const Vector3D& entry, const Vector3D& exit, double sectionRadius, Element* next):
Element(entry, exit, sectionRadius, next)
{};
StraightElement::~StraightElement() {};
bool StraightElement::isBefore(const Vector3D& position) const {
const Vector3D v(position - entryPosition);
return (-getDiagonal()).dot(v) > 0;//getDiagonal().normSquare();
}
bool StraightElement::isBeside(const Vector3D& position) const {
Vector3D X = Vector3D(position - entryPosition);
Vector3D d = getDiagonal().unit();
return (X - X.dot(d) * d).norm() > sectionRadius;
};
bool StraightElement::isAfter(const Vector3D& position) const {
const Vector3D v(position - exitPosition);
return getDiagonal().dot(v) > 0;
}
double StraightElement::getLength() const {
return getDiagonal().norm();
}
Vector3D StraightElement::getHorizontalAt(const Vector3D& position) const {
return Vector3D::k.cross(getDiagonal());
}
std::string StraightElement::getType() const {return "Straight Element";}
std::string StraightElement::toString() const {
return Element::toString();
}
void StraightElement::accept(const ElementVisitor& v) const {v.visit(this);}
StraightElement* StraightElement::clone() const {return new StraightElement(getEntryPosition(), getExitPosition(), getSectionRadius());}
}
|