diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/CurvedElement.h | 31 | ||||
-rw-r--r-- | src/main/Element.h | 32 | ||||
-rw-r--r-- | src/main/Particle.h | 10 | ||||
-rw-r--r-- | src/main/StraightElement.h | 7 | ||||
-rw-r--r-- | src/main/Vector3D.h | 2 |
5 files changed, 70 insertions, 12 deletions
diff --git a/src/main/CurvedElement.h b/src/main/CurvedElement.h index 10fd2e5..1f7116e 100644 --- a/src/main/CurvedElement.h +++ b/src/main/CurvedElement.h @@ -15,15 +15,28 @@ namespace vhc { +/** Represente un element courbe. En plus de posseder les proprietes generales d'un element, + * un element courbe a de plus une courbure et un centre de courbure. + * ==> TODO ajouter explication de la courbure + * Le centre de courbure est calcule avec la courbure et les positions des faces d'entree et de sortie d'un element. */ class CurvedElement: public Element { protected: - Vector3D curvatureCenter; + /** Courbure. */ double curvature; + /** Centre de courbure de cet element. (coord. abs. ) */ + Vector3D curvatureCenter; + public: + /** Constructeur d'elements courbes. + * @param entry position de la face d'entree + * @param exit position de face de sortie + * @param sectionRadius rayon de section de la chambre a vide + * @param curvature courbure de cet element + * @param next pointeur sur l'element suivant */ CurvedElement(const Vector3D& entry, const Vector3D& exit, double sectionRadius, double curvature, Element* next = NULL); virtual CurvedElement* copy() const {return new CurvedElement(*this);} @@ -38,6 +51,22 @@ public: return (particle.getPosition() - exitPosition).dot(out) > 0; } + double getCurvature() const {return curvature;} + + Vector3D getCurvatureCenter() const {return curvatureCenter;} + + virtual std::string getType() const {return "Curved Element";} + virtual std::string 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(); + } + + + }; } diff --git a/src/main/Element.h b/src/main/Element.h index c9432a2..b020167 100644 --- a/src/main/Element.h +++ b/src/main/Element.h @@ -8,13 +8,16 @@ #ifndef ELEMENT_H_ #define ELEMENT_H_ +#include <string> +#include <sstream> #include "Vector3D.h" #include "Particle.h" +#include "Printable.h" namespace vhc { /** Classe abstraite representant un element d'un accelerateur. */ -class Element { +class Element: public Printable { private: @@ -38,7 +41,7 @@ protected: Element *next; /* Intensité (constante) du champ. - * TODO à améliorer + * à améliorer double fieldIntensity; Vector3D magneticField @@ -48,6 +51,11 @@ protected: public: + /** Constructeur d'elements. + * @param entry position de la face d'entree + * @param exit position de face de sortie + * @param sectionRadius rayon de section de la chambre a vide + * @param next pointeur sur l'element suivant */ Element(const Vector3D& entry, const Vector3D& exit, double sectionRadius, Element* next = NULL): entryPosition(entry), exitPosition(exit), @@ -58,8 +66,10 @@ public: * ATTENTION: La delocation de memoire est sous la responsabilite de l'appelant. */ virtual Element* copy() const = 0; + /** Determine si la particule donnee a heurte le bord de cet element. */ virtual bool isOutside(const Particle& particle) const = 0; + /** Determine si la particule donnee a passe cet element. */ /* TODO Et si la valeur de retour était un pointeur? */ virtual bool isPast(const Particle& particle) const = 0; @@ -71,13 +81,13 @@ public: Vector3D getEntryPosition() const {return entryPosition;} /** Assigne la position d'entree. */ - void setEntryPosition(const Vector3D& newPos) {entryPosition = newPos;} + //void setEntryPosition(const Vector3D& newPos) {entryPosition = newPos;} /** Retourne la position de sortie. */ Vector3D getExitPosition() const {return exitPosition;} /** Assigne la position de sortie. */ - void setExitPosition(const Vector3D& newPos) {exitPosition = newPos;} + //void setExitPosition(const Vector3D& newPos) {exitPosition = newPos;} /** Retourne le rayon de la section de cet element. */ double getSectionRadius() const {return sectionRadius;} @@ -89,9 +99,21 @@ public: Element* getNext() const {return next;} /** Assigne un pointeur sur l'element suivant. */ - //TODO use pointer? void setNext(Element* n) {next = n;} + bool isConnected() const {return next != NULL;} + + virtual std::string getType() const {return "Element";} + virtual std::string toString() const { + std::stringstream s; + s << getType() << ":\n"; + s << "\tentry: " << getEntryPosition() << "\n"; + s << "\texit: " << getExitPosition() << "\n"; + s << "\tsection radius: " << getSectionRadius() << "\n"; + s << "\tconnected: " << (isConnected() ? "true" : "false"); + return s.str(); + } + }; } diff --git a/src/main/Particle.h b/src/main/Particle.h index e6ee44f..d2cc7d8 100644 --- a/src/main/Particle.h +++ b/src/main/Particle.h @@ -95,11 +95,11 @@ public: virtual std::string toString() const { std::stringstream s; s << "Particle:" << "\n"; - s << "\tPosition: " << position << "\n"; - s << "\tVelocity: " << velocity << "\n"; - s << "\tMass: " << mass << "\n"; - s << "\tCharge: " << charge << "\n"; - s << "\tForce: " << force << "\n"; + s << "\tposition: " << position << "\n"; + s << "\tvelocity: " << velocity << "\n"; + s << "\tmass: " << mass << "\n"; + s << "\tcharge: " << charge << "\n"; + s << "\tforce: " << force << "\n"; return s.str(); } diff --git a/src/main/StraightElement.h b/src/main/StraightElement.h index fa84846..8ce4db0 100644 --- a/src/main/StraightElement.h +++ b/src/main/StraightElement.h @@ -36,6 +36,13 @@ public: return getDiagonal().dot(v) > getDiagonal().dot(getDiagonal()); } + virtual std::string getType() const {return "Straight Element";} + virtual std::string toString() const { + std::stringstream s; + s << Element::toString(); + return s.str(); + } + }; } diff --git a/src/main/Vector3D.h b/src/main/Vector3D.h index 5c8d5b5..6d4dfed 100644 --- a/src/main/Vector3D.h +++ b/src/main/Vector3D.h @@ -103,7 +103,7 @@ public: /** Retourne une représentation en chaîne de caractères de ce vecteur. */ virtual std::string toString() const { std::stringstream s; - s << "Vector3D(" << x << ", " << y << ", " << z << ")"; + s << "(" << x << ", " << y << ", " << z << ")"; return s.str(); }; |