summaryrefslogtreecommitdiff
path: root/src/main/StraightElement.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/StraightElement.h')
-rw-r--r--src/main/StraightElement.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main/StraightElement.h b/src/main/StraightElement.h
new file mode 100644
index 0000000..5a1d944
--- /dev/null
+++ b/src/main/StraightElement.h
@@ -0,0 +1,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_ */