diff options
author | Jakob Odersky <jodersky@gmail.com> | 2011-03-22 15:01:48 +0000 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2011-03-22 15:01:48 +0000 |
commit | f483d78ba331e059af7486af23dcee2e4c0a83d9 (patch) | |
tree | 2e472c5c5c382d2e574968eb2a54a4cc67b8ff62 | |
parent | fb7d649f61bdfe16be960696734aaab322d50b95 (diff) | |
download | vhc-f483d78ba331e059af7486af23dcee2e4c0a83d9.tar.gz vhc-f483d78ba331e059af7486af23dcee2e4c0a83d9.tar.bz2 vhc-f483d78ba331e059af7486af23dcee2e4c0a83d9.zip |
Ajoute elements courbes et droits. Leur implementation est en cours...
-rw-r--r-- | src/main/Courbe.cc | 21 | ||||
-rw-r--r-- | src/main/Courbe.h | 28 | ||||
-rw-r--r-- | src/main/Curved.cc | 28 | ||||
-rw-r--r-- | src/main/Curved.h | 30 | ||||
-rw-r--r-- | src/main/Element.cc | 5 | ||||
-rw-r--r-- | src/main/Element.h | 28 | ||||
-rw-r--r-- | src/main/Straight.cc | 21 | ||||
-rw-r--r-- | src/main/Straight.h | 27 |
8 files changed, 125 insertions, 63 deletions
diff --git a/src/main/Courbe.cc b/src/main/Courbe.cc deleted file mode 100644 index 4318c97..0000000 --- a/src/main/Courbe.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Courbe.cc - * - * Created on: 21 mars 2011 - * Author: christian - */ - -#include "Courbe.h" - -namespace vhc { - -Courbe::Courbe(): courbureCenter(0,0,0) { - // TODO Auto-generated constructor stub - -} - -Courbe::~Courbe() { - // TODO Auto-generated destructor stub -} - -} diff --git a/src/main/Courbe.h b/src/main/Courbe.h deleted file mode 100644 index b316632..0000000 --- a/src/main/Courbe.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Courbe.h - * - * Created on: 21 mars 2011 - * Author: christian - */ - -#ifndef COURBE_H_ -#define COURBE_H_ - -#include<Element.h> - -namespace vhc { - -class Courbe : public Element { -protected: - /** Postion de centre de courbure - * (rayon de courbure implicite). */ - Vector3D courbureCenter; - -public: - Courbe(); - virtual ~Courbe(); -}; - -} - -#endif /* COURBE_H_ */ diff --git a/src/main/Curved.cc b/src/main/Curved.cc new file mode 100644 index 0000000..49a50eb --- /dev/null +++ b/src/main/Curved.cc @@ -0,0 +1,28 @@ +/* + * Curved.cc + * + * Created on: Mar 22, 2011 + * Author: jakob + */ + +#include "Curved.h" + +namespace vhc { + +Curved::Curved(const Vector3D& entry, const Vector3D& exit, double sectionRadius, double curvatureRadius, Element* next = NULL): + entryPosition(entry), + exitPosition(exit), + sectionRadius(sectionRadius), + next(next) { + + double orientation = signum(curvatureRadius); + Vector3D bisector = getDiagonal().cross(Vector3D::k); + double halfLength = (getDiagonal() / 2).norm(); + Vector3D midpoint = getEntryPoisition() + getDiagonal() / 2; + + centerOfCurvature = midpoint + bisector.unit() * + sqrt(curvatureRadius * curvatureRadius - halfLength * halfLength) * + orientation; +}; + +} diff --git a/src/main/Curved.h b/src/main/Curved.h new file mode 100644 index 0000000..878de1b --- /dev/null +++ b/src/main/Curved.h @@ -0,0 +1,30 @@ +/* + * Curved.h + * + * Created on: Mar 22, 2011 + * Author: jakob + */ + +#ifndef CURVED_H_ +#define CURVED_H_ + +#include <math.h> +#include "Vector3D.h" + +namespace vhc { + +//TODO implement abstract methods of Element +class Curved: public Element { + +protected: + + Vector3D centerOfCurvature; + +public: + + Curved(const Vector3D& entry, const Vector3D& exit, double sectionRadius, double curvatureRadius, Element* next = NULL); +}; + +} + +#endif /* CURVED_H_ */ diff --git a/src/main/Element.cc b/src/main/Element.cc index 36e08de..f1e1154 100644 --- a/src/main/Element.cc +++ b/src/main/Element.cc @@ -9,13 +9,10 @@ namespace vhc { -//Element::Element() { +//Element::Element(const Vector3D& entryPosition) { // TODO Auto-generated constructor stub //} -//Element::~Element() { - // TODO Auto-generated destructor stub -//} } diff --git a/src/main/Element.h b/src/main/Element.h index 754287f..448126f 100644 --- a/src/main/Element.h +++ b/src/main/Element.h @@ -29,35 +29,43 @@ protected: Vector3D exitPosition; /** Rayon de la chambre à vide. */ - double radius; + double sectionRadius; /** Pointeur sur l'élément suivant. */ Element *next; - /** Intensité (constante) du champ. - * TODO à améliorer */ - double fieldIntensity; + /* Intensité (constante) du champ. + * TODO à améliorer + double fieldIntensity; + Vector3D magneticField - /** Direction du champ magnétique, invariant dans l'espace. */ - Vector3D fieldDirection; + /** Direction du champ magnétique, invariant dans l'espace. + Vector3D fieldDirection; + */ public: - Element(); - virtual ~Element(); + Element(const Vector3D& entry, const Vector3D& exit, double sectionRadius, Element* next = NULL): + entryPosition(entry), + exitPosition(exit), + sectionRadius(sectionRadius), + next(next) + {}; virtual bool isOutside(const Particle& p) const = 0; /* TODO Et si la valeur de retour était un pointeur? */ virtual bool isPast(const Particle& p) const = 0; + Vector3D getDiagonal() const {return exitPosition - entryPosition;} + Vector3D getEntryPosition() const {return entryPosition;} void setEntryPosition(const Vector3D& newPos) {entryPosition = newPos;} Vector3D getExitPosition() const {return exitPosition;} void setExitPosition(const Vector3D& newPos) {exitPosition = newPos;} - double getRadius() const {return radius;} - void setRadius(double r) {radius = r;} + double getSectionRadius() const {return sectionRadius;} + void setSectionRadius(double r) {sectionRadius = r;} Element* getNext() const {return next;} diff --git a/src/main/Straight.cc b/src/main/Straight.cc new file mode 100644 index 0000000..943d025 --- /dev/null +++ b/src/main/Straight.cc @@ -0,0 +1,21 @@ +/* + * Straight.cc + * + * Created on: Mar 22, 2011 + * Author: jakob + */ + +#include "Straight.h" + +namespace vhc { + +Straight::Straight() { + // TODO Auto-generated constructor stub + +} + +Straight::~Straight() { + // TODO Auto-generated destructor stub +} + +} diff --git a/src/main/Straight.h b/src/main/Straight.h new file mode 100644 index 0000000..8b0a055 --- /dev/null +++ b/src/main/Straight.h @@ -0,0 +1,27 @@ +/* + * Straight.h + * + * Created on: Mar 22, 2011 + * Author: jakob + */ + +#ifndef STRAIGHT_H_ +#define STRAIGHT_H_ + +#include "Element.h" + +namespace vhc { + +//TODO everything +class Straight: public Element { + +public: + Straight(); + + + virtual ~Straight(); +}; + +} + +#endif /* STRAIGHT_H_ */ |