summaryrefslogtreecommitdiff
path: root/src/main/CurvedElement.cc
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2011-04-17 20:05:38 +0000
committerJakob Odersky <jodersky@gmail.com>2011-04-17 20:05:38 +0000
commit964f0f8a7c88c1128c2edbef1fb36a86ed9864cf (patch)
tree38ef5ce1e578e7a40f3b08d30cee8666f0bea2e4 /src/main/CurvedElement.cc
parent064e27d5e7bf451542cc89ee0a05a06447acdc88 (diff)
downloadvhc-964f0f8a7c88c1128c2edbef1fb36a86ed9864cf.tar.gz
vhc-964f0f8a7c88c1128c2edbef1fb36a86ed9864cf.tar.bz2
vhc-964f0f8a7c88c1128c2edbef1fb36a86ed9864cf.zip
Migration de tous les implementations dans les fichier .h vers les fichiers .cc
Diffstat (limited to 'src/main/CurvedElement.cc')
-rw-r--r--src/main/CurvedElement.cc36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/main/CurvedElement.cc b/src/main/CurvedElement.cc
index 16816d9..1afae38 100644
--- a/src/main/CurvedElement.cc
+++ b/src/main/CurvedElement.cc
@@ -5,9 +5,9 @@
* Author: jakob
*/
-#include <assert.h>
#include <math.h>
-#include "exception.h"
+#include <sstream>
+#include "exceptions.h"
#include "CurvedElement.h"
using namespace std;
@@ -15,7 +15,6 @@ namespace vhc {
/** Cf. CurvedElement.h */
CurvedElement::CurvedElement(const Vector3D& entry, const Vector3D& exit, double sectionRadius, double curvature, Element* next):
-
Element(entry, exit, sectionRadius, next),
curvature(curvature),
curvatureCenter(Vector3D::Null) {
@@ -31,4 +30,35 @@ CurvedElement::CurvedElement(const Vector3D& entry, const Vector3D& exit, double
curvatureCenter = midpoint + 1 / k * sqrt(1.0 - (k * k) / 4 * getDiagonal().normSquare()) * (getDiagonal().unit().cross(Vector3D::k));
}
+CurvedElement::~CurvedElement() {};
+
+double CurvedElement::getCurvature() const {return curvature;}
+
+Vector3D CurvedElement::getCurvatureCenter() const {return curvatureCenter;}
+
+double CurvedElement::getAngle() const {
+ return acos((entryPosition - curvatureCenter).unit().dot((exitPosition - curvatureCenter).unit()));
+}
+
+bool CurvedElement::hasHit(const Particle& particle) const {
+ Vector3D x(particle.getPosition() - entryPosition);
+ if (x == Vector3D::Null) return false;
+ else return (x - Vector3D(x.getX(), x.getY(), 0).unit() / fabs(curvature)).norm() > sectionRadius;
}
+
+bool CurvedElement::isPast(const Particle& particle) const {
+ Vector3D out = (entryPosition - curvatureCenter).cross(exitPosition - curvatureCenter).cross(entryPosition - curvatureCenter);
+ return (particle.getPosition() - exitPosition).dot(out) > 0;
+}
+
+std::string CurvedElement::getType() const {return "Curved Element";}
+std::string CurvedElement::toString() const {
+ std::stringstream s;
+ s << Element::toString() << "\n";
+ s << "\tcurvature: " << getCurvature() << "\n";
+ s << "\tcurvature radius: " << 1.0 / getCurvature() << "\n";
+ s << "\tcurvature center: " << getCurvatureCenter();
+ return s.str();
+}
+
+} //vhc