diff options
author | Jakob Odersky <jodersky@gmail.com> | 2011-04-17 20:24:32 +0000 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2011-04-17 20:24:32 +0000 |
commit | fa155ede4af523228b455015312f5ebbb0fec183 (patch) | |
tree | 97c113c8eea4bdbde2e56ac9cc53ec3d8ce5bd99 | |
parent | 964f0f8a7c88c1128c2edbef1fb36a86ed9864cf (diff) | |
download | vhc-fa155ede4af523228b455015312f5ebbb0fec183.tar.gz vhc-fa155ede4af523228b455015312f5ebbb0fec183.tar.bz2 vhc-fa155ede4af523228b455015312f5ebbb0fec183.zip |
Repare erreur commise dans Vector3D, dans la revision precedente.
-rw-r--r-- | src/gui/Makefile | 2 | ||||
-rw-r--r-- | src/main/ElementVisitor.h | 3 | ||||
-rw-r--r-- | src/main/Particle.cc | 4 | ||||
-rw-r--r-- | src/main/Particle.h | 8 | ||||
-rw-r--r-- | src/main/Vector3D.cc | 40 | ||||
-rw-r--r-- | src/main/Vector3D.h | 1 | ||||
-rw-r--r-- | src/test/VisitorTest.cc | 6 |
7 files changed, 33 insertions, 31 deletions
diff --git a/src/gui/Makefile b/src/gui/Makefile index b9bd9e6..682ca97 100644 --- a/src/gui/Makefile +++ b/src/gui/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: $(BINDIR)/gui/gui -# Generated by qmake (2.01a) (Qt 4.7.0) on: Sun Apr 17 21:55:28 2011 +# Generated by qmake (2.01a) (Qt 4.7.0) on: Sun Apr 17 22:20:53 2011 # Project: gui.pro # Template: app # Command: /usr/bin/qmake -o Makefile gui.pro diff --git a/src/main/ElementVisitor.h b/src/main/ElementVisitor.h index 126c9ce..49247df 100644 --- a/src/main/ElementVisitor.h +++ b/src/main/ElementVisitor.h @@ -10,12 +10,9 @@ namespace vhc { - class StraightElement; class Quadrupole; -class CurvedElement; class Dipole; -class CompositeElement; class ElementVisitor { diff --git a/src/main/Particle.cc b/src/main/Particle.cc index a3f80cd..3609e01 100644 --- a/src/main/Particle.cc +++ b/src/main/Particle.cc @@ -77,5 +77,9 @@ std::string Particle::toString() const { Particle* Particle::clone() const {return new Particle(*this);} +Element* Particle::getElement() const {return element;} + +void Particle::setElement(Element* element) {element = element;} + } //vhc diff --git a/src/main/Particle.h b/src/main/Particle.h index bc2d67a..dbd5a6d 100644 --- a/src/main/Particle.h +++ b/src/main/Particle.h @@ -17,6 +17,8 @@ namespace vhc { +class Element; //forward declaration + /** Classe représentant une particule * TODO !!! changer le unites en SI pour la representation interne. * TODO poser question sur l'energie, gamma, qdm @@ -43,7 +45,7 @@ private: /** Facteur gamma de cette particule. [1] */ double gamma; - //Element* element; + Element* element; public: @@ -105,8 +107,8 @@ public: virtual Particle* clone() const; - //void setElement(Element* element) {element = element;} - //Element* getElement() const {return element;} + Element* getElement() const; + void setElement(Element* element); }; diff --git a/src/main/Vector3D.cc b/src/main/Vector3D.cc index b733e2e..846ef03 100644 --- a/src/main/Vector3D.cc +++ b/src/main/Vector3D.cc @@ -5,7 +5,7 @@ * Author: Jakob Odersky */ -#include <iostream> +#include <sstream> #include "Vector3D.h" using namespace std; @@ -14,43 +14,43 @@ namespace vhc { Vector3D::Vector3D(double _x, double _y, double _z) : x(_x), y(_y), z(_z), normCache(-1) {}; -inline double Vector3D::getX() const {return x;}; +double Vector3D::getX() const {return x;}; -inline double Vector3D::getY() const {return y;}; +double Vector3D::getY() const {return y;}; -inline double Vector3D::getZ() const {return z;}; +double Vector3D::getZ() const {return z;}; -inline bool Vector3D::operator== (const Vector3D& v) const {return x == v.x && y == v.y && z == v.z;}; +bool Vector3D::operator== (const Vector3D& v) const {return x == v.x && y == v.y && z == v.z;}; -inline bool Vector3D::operator!= (const Vector3D& v) const {return !((*this) == (v));}; +bool Vector3D::operator!= (const Vector3D& v) const {return !((*this) == (v));}; -inline Vector3D Vector3D::operator+ (const Vector3D& v) const {return Vector3D(x + v.x, y + v.y, z + v.z);}; +Vector3D Vector3D::operator+ (const Vector3D& v) const {return Vector3D(x + v.x, y + v.y, z + v.z);}; -inline Vector3D Vector3D::operator* (double n) const {return Vector3D(x * n, y * n, z * n);}; +Vector3D Vector3D::operator* (double n) const {return Vector3D(x * n, y * n, z * n);}; -inline Vector3D Vector3D::operator- () const {return (*this) * (-1.0);}; +Vector3D Vector3D::operator- () const {return (*this) * (-1.0);}; -inline Vector3D Vector3D::operator- (const Vector3D& v) const {return (*this) + -v;}; +Vector3D Vector3D::operator- (const Vector3D& v) const {return (*this) + -v;}; -inline Vector3D Vector3D::operator/ (double n) const {return (*this) * (1.0 / n) ;}; +Vector3D Vector3D::operator/ (double n) const {return (*this) * (1.0 / n) ;}; -inline double Vector3D::dot(const Vector3D& v) const {return x * v.x + y * v.y + z * v.z;}; +double Vector3D::dot(const Vector3D& v) const {return x * v.x + y * v.y + z * v.z;}; -inline Vector3D Vector3D::cross(const Vector3D& v) const {return Vector3D(y * v.z - v.y * z, v.x * z - x * v.z, x * v.y - v.x * y);}; +Vector3D Vector3D::cross(const Vector3D& v) const {return Vector3D(y * v.z - v.y * z, v.x * z - x * v.z, x * v.y - v.x * y);}; -inline Vector3D Vector3D::operator~ () const { +Vector3D Vector3D::operator~ () const { if (norm() != 0.0) return (*this) / norm(); else throw UnsupportedOperationException("Zero vector does not have a unit vector."); }; -inline Vector3D Vector3D::unit() const {return ~(*this);} +Vector3D Vector3D::unit() const {return ~(*this);} -inline double Vector3D::norm() const { +double Vector3D::norm() const { if (normCache == -1) normCache = sqrt(dot(*this)); return normCache; } -inline double Vector3D::normSquare() const {return dot(*this);} +double Vector3D::normSquare() const {return dot(*this);} std::string Vector3D::toString() const { std::stringstream s; @@ -58,11 +58,11 @@ std::string Vector3D::toString() const { return s.str(); }; -inline double Vector3D::angle(const Vector3D& v) const {return acos(dot(v) / norm() / v.norm());} +double Vector3D::angle(const Vector3D& v) const {return acos(dot(v) / norm() / v.norm());} -inline double Vector3D::tripleProduct(const Vector3D& v, const Vector3D& w) const { return dot(v.cross(w)); } +double Vector3D::tripleProduct(const Vector3D& v, const Vector3D& w) const { return dot(v.cross(w)); } -inline Vector3D Vector3D::rotate(const Vector3D& axis, double t) const { +Vector3D Vector3D::rotate(const Vector3D& axis, double t) const { const Vector3D& x = *this; const Vector3D& a = ~axis; return x * cos(t) + a * x.dot(a) * (1-cos(t)) + a.cross(x) * sin(t); diff --git a/src/main/Vector3D.h b/src/main/Vector3D.h index c4935e2..48a6c81 100644 --- a/src/main/Vector3D.h +++ b/src/main/Vector3D.h @@ -8,7 +8,6 @@ #ifndef VECTOR3D_H_ #define VECTOR3D_H_ -#include <sstream> #include <math.h> #include "exceptions.h" #include "Printable.h" diff --git a/src/test/VisitorTest.cc b/src/test/VisitorTest.cc index f42f4a6..024e7b5 100644 --- a/src/test/VisitorTest.cc +++ b/src/test/VisitorTest.cc @@ -22,15 +22,15 @@ using namespace vhc; class PrintVisitor: public ElementVisitor { public: - virtual void visit(StraightElement* straight) { + virtual void visit(const StraightElement* straight) const { cout << "A straight element." << endl; } - virtual void visit(Quadrupole* quadrupole) { + virtual void visit(const Quadrupole* quadrupole) const { cout << "A quadrupole." << endl; } - virtual void visit(Dipole* dipole) { + virtual void visit(const Dipole* dipole) const { cout << "A dipole." << endl; } |