homoefeld berechnung und animation sollten grundlegend funktionieren
git-svn-id: http://svn.lsim.tuxzone.org/trunk@3 4bec179b-ab65-46ed-a5f8-55b8b5c735d0
This commit is contained in:
Binary file not shown.
@@ -6,13 +6,13 @@
|
|||||||
<View0 Encoding="" Type="Source" />
|
<View0 Encoding="" Type="Source" />
|
||||||
</Doc0>
|
</Doc0>
|
||||||
<Doc1 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsellipseitem.cpp" >
|
<Doc1 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsellipseitem.cpp" >
|
||||||
<View0 Encoding="" line="85" Type="Source" />
|
<View0 Encoding="" line="66" Type="Source" />
|
||||||
</Doc1>
|
</Doc1>
|
||||||
<Doc2 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsellipseitem.h" >
|
<Doc2 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsellipseitem.h" >
|
||||||
<View0 Encoding="" line="60" Type="Source" />
|
<View0 Encoding="" Type="Source" />
|
||||||
</Doc2>
|
</Doc2>
|
||||||
<Doc3 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/simulscene.cpp" >
|
<Doc3 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/simulscene.cpp" >
|
||||||
<View0 Encoding="" line="39" Type="Source" />
|
<View0 Encoding="" Type="Source" />
|
||||||
</Doc3>
|
</Doc3>
|
||||||
<Doc4 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/constants.h" >
|
<Doc4 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/constants.h" >
|
||||||
<View0 Encoding="" Type="Source" />
|
<View0 Encoding="" Type="Source" />
|
||||||
|
|||||||
@@ -18,4 +18,5 @@
|
|||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
const double PI = acos( -1.0 );
|
const double PI = acos( -1.0 );
|
||||||
|
const double SPEED_OF_LIGHT = 2.99792458e+8;
|
||||||
@@ -24,6 +24,8 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "simulscene.h"
|
#include "simulscene.h"
|
||||||
#include "probechargewidget.h"
|
#include "probechargewidget.h"
|
||||||
|
#include <cmath>
|
||||||
|
#include "constants.h"
|
||||||
|
|
||||||
GraphicsEllipseItem::GraphicsEllipseItem() {
|
GraphicsEllipseItem::GraphicsEllipseItem() {
|
||||||
setFlag(ItemIsMovable);
|
setFlag(ItemIsMovable);
|
||||||
@@ -77,18 +79,22 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint, double startSpe
|
|||||||
|
|
||||||
|
|
||||||
for(int i = 1; i< steps;++i) {
|
for(int i = 1; i< steps;++i) {
|
||||||
|
double myMasse = getMasse( sqrt( speedListX->at(i-1)*speedListX->at(i-1) + speedListY->at(i-1)*speedListY->at(i-1) ) );
|
||||||
|
qDebug()<< myMasse;
|
||||||
double powerX = myScene->getPowerAt(currProbePath->at(i-1), charge, 'x');
|
double powerX = myScene->getPowerAt(currProbePath->at(i-1), charge, 'x');
|
||||||
double powerY = myScene->getPowerAt(currProbePath->at(i-1), charge, 'y');
|
double powerY = myScene->getPowerAt(currProbePath->at(i-1), charge, 'y');
|
||||||
double deltaDistXconst = speedListX->at(i-1) * (timePerStep/1000.0);
|
double deltaDistXconst = speedListX->at(i-1) * (timePerStep/1000.0); //v0*t
|
||||||
double deltaDistYconst = speedListY->at(i-1) * (timePerStep/1000.0);
|
double deltaDistYconst = speedListY->at(i-1) * (timePerStep/1000.0);
|
||||||
double deltaDistXaccel = 0.5 * (powerX/getMasse()) * (timePerStep/1000.0) * (timePerStep/1000.0);
|
|
||||||
double deltaDistYaccel = 0.5 * (powerY/getMasse()) * (timePerStep/1000.0) * (timePerStep/1000.0);
|
double deltaDistXaccel = 0.5 * (powerX/myMasse * (timePerStep/1000.0) * (timePerStep/1000.0)); // 1/2 * F/m * t*t
|
||||||
|
double deltaDistYaccel = 0.5 * (powerY/myMasse * (timePerStep/1000.0) * (timePerStep/1000.0));
|
||||||
|
|
||||||
double deltaDistX = (deltaDistXconst + deltaDistXaccel);
|
double deltaDistX = (deltaDistXconst + deltaDistXaccel);
|
||||||
double deltaDistY = (deltaDistYconst + deltaDistYaccel);
|
double deltaDistY = (deltaDistYconst + deltaDistYaccel);
|
||||||
|
|
||||||
currProbePath->append(QPointF(currProbePath->at(i-1).x() + deltaDistX/meterPerPx,currProbePath->at(i-1).y() + deltaDistY/meterPerPx));
|
currProbePath->append(QPointF(currProbePath->at(i-1).x() + deltaDistX/meterPerPx ,currProbePath->at(i-1).y() + deltaDistY/meterPerPx));
|
||||||
speedListX->append(speedListX->at(i-1) + (powerX/getMasse()) * (timePerStep/1000.0));
|
speedListX->append(speedListX->at(i-1) + (powerX/myMasse * (timePerStep/1000.0)) );
|
||||||
speedListY->append(speedListY->at(i-1) + (powerY/getMasse()) * (timePerStep/1000.0));
|
speedListY->append(speedListY->at(i-1) + (powerY/myMasse * (timePerStep/1000.0)) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +102,6 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint, double startSpe
|
|||||||
qDebug()<< "Probe Path: " <<*currProbePath;
|
qDebug()<< "Probe Path: " <<*currProbePath;
|
||||||
qDebug()<< "speed x: "<<*speedListX;
|
qDebug()<< "speed x: "<<*speedListX;
|
||||||
qDebug()<< "speed y: "<<*speedListY;
|
qDebug()<< "speed y: "<<*speedListY;
|
||||||
qDebug()<<currProbePath->at(12);
|
|
||||||
qDebug()<<speedListY->at(12);
|
qDebug()<<speedListY->at(12);
|
||||||
qDebug()<<"power x: "<< (double)myScene->getPowerAt(QPointF(0,0), charge, 'x');
|
qDebug()<<"power x: "<< (double)myScene->getPowerAt(QPointF(0,0), charge, 'x');
|
||||||
qDebug()<<"power y: " << (double)myScene->getPowerAt(QPointF(0,0), charge, 'y');
|
qDebug()<<"power y: " << (double)myScene->getPowerAt(QPointF(0,0), charge, 'y');
|
||||||
@@ -104,12 +109,16 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint, double startSpe
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long double GraphicsEllipseItem::getMasse() const {
|
double GraphicsEllipseItem::getMasse(double speed) {
|
||||||
return masse;
|
if(speed == 0) return masse;
|
||||||
|
else {
|
||||||
|
return masse / (sqrt(1- ( (speed/SPEED_OF_LIGHT)*(speed/SPEED_OF_LIGHT))));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphicsEllipseItem::setMasse ( const long double& theValue ) {
|
void GraphicsEllipseItem::setMasse ( const double& theValue ) {
|
||||||
if (masse == theValue) return;
|
if (masse == theValue) return;
|
||||||
masse = theValue;
|
masse = theValue;
|
||||||
}
|
}
|
||||||
@@ -129,3 +138,7 @@ QWidget * GraphicsEllipseItem::getDockWidget() const
|
|||||||
{
|
{
|
||||||
return myProbeChargeWidget;
|
return myProbeChargeWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QPointF> * GraphicsEllipseItem::getCurrProbePath() {
|
||||||
|
return currProbePath;
|
||||||
|
}
|
||||||
@@ -32,6 +32,8 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
|
|||||||
QWidget* getDockWidget() const;
|
QWidget* getDockWidget() const;
|
||||||
|
|
||||||
~GraphicsEllipseItem();
|
~GraphicsEllipseItem();
|
||||||
|
QList<QPointF> * getCurrProbePath();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -58,12 +60,15 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
|
|||||||
/*!
|
/*!
|
||||||
\param steps Anzahl der auszufürenden Schriite
|
\param steps Anzahl der auszufürenden Schriite
|
||||||
*/
|
*/
|
||||||
void calculateProbePath (QPointF startPoint = QPointF(0,0), double startSpeedX = 0, double startSpeedY = 0);
|
void calculateProbePath (QPointF startPoint = QPointF(0,0) , double startSpeedX = 0, double startSpeedY = 0);
|
||||||
|
|
||||||
void setMasse ( const long double& theValue );
|
void setMasse ( const double& theValue );
|
||||||
|
|
||||||
|
//! Gibt die Masse zurück
|
||||||
long double getMasse() const;
|
/*!
|
||||||
|
\param speed alles != 0 relativistisch
|
||||||
|
*/
|
||||||
|
double getMasse(double speed);
|
||||||
|
|
||||||
void setCharge ( const long double& theValue );
|
void setCharge ( const long double& theValue );
|
||||||
|
|
||||||
|
|||||||
26
src/lsim.cpp
26
src/lsim.cpp
@@ -147,10 +147,25 @@ void lsim::createScene() {
|
|||||||
void lsim::createDocks() {
|
void lsim::createDocks() {
|
||||||
QPushButton *button1 = new QPushButton("Loeschen");
|
QPushButton *button1 = new QPushButton("Loeschen");
|
||||||
QPushButton *button2 = new QPushButton("calculate");
|
QPushButton *button2 = new QPushButton("calculate");
|
||||||
ExpDoubleSpinBox *box = new ExpDoubleSpinBox;
|
|
||||||
box->setRange(-pow(10,33), pow(10,33));
|
|
||||||
box->setDecimals(4);
|
ExpDoubleSpinBox *time_step_box = new ExpDoubleSpinBox;
|
||||||
//box->setSuffix(" V");
|
time_step_box->setRange(-pow(10,33), pow(10,33));
|
||||||
|
time_step_box->setDecimals(20);
|
||||||
|
time_step_box->setKeyboardTracking(false);
|
||||||
|
|
||||||
|
time_step_box->setValue(simulscene->getTimePerStep());
|
||||||
|
connect(time_step_box, SIGNAL(valueChanged(double)),simulscene, SLOT(setTimePerStep(double)));
|
||||||
|
connect(simulscene, SIGNAL(timePerStepChanged(double)),time_step_box, SLOT(setValue( double )));
|
||||||
|
|
||||||
|
|
||||||
|
ExpDoubleSpinBox *meter_per_px_box = new ExpDoubleSpinBox;
|
||||||
|
meter_per_px_box->setRange(-pow(10,33), pow(10,33));
|
||||||
|
meter_per_px_box->setDecimals(20);
|
||||||
|
meter_per_px_box->setKeyboardTracking(false);
|
||||||
|
meter_per_px_box->setValue(simulscene->getMeterPerPx());
|
||||||
|
connect(meter_per_px_box, SIGNAL(valueChanged(double)),simulscene, SLOT(setMeterPerPx(double)));
|
||||||
|
connect(simulscene, SIGNAL(meterPerPxChanged(double)),meter_per_px_box, SLOT(setValue( double )));
|
||||||
|
|
||||||
QSlider *slider1 = new QSlider();
|
QSlider *slider1 = new QSlider();
|
||||||
slider1->setMinimum(0);
|
slider1->setMinimum(0);
|
||||||
@@ -163,7 +178,8 @@ void lsim::createDocks() {
|
|||||||
layout->addWidget(button1);
|
layout->addWidget(button1);
|
||||||
layout->addWidget(button2);
|
layout->addWidget(button2);
|
||||||
layout->addWidget(slider1);
|
layout->addWidget(slider1);
|
||||||
layout->addWidget(box);
|
layout->addWidget(time_step_box);
|
||||||
|
layout->addWidget(meter_per_px_box);
|
||||||
QWidget *widget2 = new QWidget;
|
QWidget *widget2 = new QWidget;
|
||||||
widget2->setLayout(layout);
|
widget2->setLayout(layout);
|
||||||
|
|
||||||
|
|||||||
@@ -74,32 +74,25 @@ SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
|
|||||||
|
|
||||||
addItem(ellipse1);
|
addItem(ellipse1);
|
||||||
|
|
||||||
timer = new QTimeLine( (200e-3/8.0e+6) *1000 * 2e+8);
|
timer = new QTimeLine( 30000);
|
||||||
//qDebug()<< (200e-3/8.0e+6) *1000 * 2e+8;
|
//qDebug()<< (200e-3/8.0e+6) *1000 * 2e+8;
|
||||||
timer->setFrameRange(0,100);
|
timer->setFrameRange(0,100);
|
||||||
timer->setUpdateInterval(25);
|
timer->setUpdateInterval(25);
|
||||||
timer->setCurveShape(QTimeLine::LinearCurve);
|
timer->setCurveShape(QTimeLine::LinearCurve);
|
||||||
//timer->toggleDirection();
|
//timer->toggleDirection();
|
||||||
QGraphicsItemAnimation *ani = new QGraphicsItemAnimation();
|
ani = new QGraphicsItemAnimation();
|
||||||
ani->setItem(ellipse1);
|
ani->setItem(ellipse1);
|
||||||
ani->setTimeLine(timer);
|
ani->setTimeLine(timer);
|
||||||
|
|
||||||
qreal E = 40/(2e-2);
|
|
||||||
qreal q = -1.6022e-19;
|
|
||||||
qreal m = 9.1094e-31;
|
|
||||||
qreal vx = 8.0e+6;
|
|
||||||
qreal ax=0;
|
|
||||||
qreal ay=q*E/m;
|
|
||||||
|
|
||||||
for (int i=0; i<=200; ++i) {
|
|
||||||
qreal x=i;
|
|
||||||
ani->setPosAt(i/200.0, QPointF(x , 0.5 * ay * pow(( (x/1000) /vx),2) *1000 ));
|
|
||||||
//ani->setPosAt((t+360)/720.0, QPointF((t), 80*abs(t/180.0*3.14) ));
|
|
||||||
//qDebug()<<QPointF(x , 0.5 * ay * pow(( (x/1000) /vx),2) *1000 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulScene::startTimer() {
|
void SimulScene::startTimer() {
|
||||||
|
for (int i=0; i<getSteps(); ++i) {
|
||||||
|
//ani->setPosAt(i/200.0, QPointF(x , 0.5 * ay * pow(( (x/1000) /vx),2) *1000 ));
|
||||||
|
ani->setPosAt(i/(double)getSteps(), ellipse1->getCurrProbePath()->at(i) );
|
||||||
|
//qDebug()<< getSteps();
|
||||||
|
}
|
||||||
timer->start();
|
timer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +490,7 @@ void SimulScene::setTimePerStep(double time) {
|
|||||||
\fn SimulScene::startCalculation()
|
\fn SimulScene::startCalculation()
|
||||||
*/
|
*/
|
||||||
void SimulScene::startCalculation() {
|
void SimulScene::startCalculation() {
|
||||||
ellipse1->calculateProbePath();
|
ellipse1->calculateProbePath(ellipse1->pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -519,8 +512,8 @@ void SimulScene::setSteps(int steps) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long double SimulScene::getPowerAt(QPointF point, long double charge, char xy) {
|
double SimulScene::getPowerAt(QPointF point, double charge, char xy) {
|
||||||
long double dPower = 0;
|
double dPower = 0;
|
||||||
for(int i = 0; i < items(point).size(); ++i) {
|
for(int i = 0; i < items(point).size(); ++i) {
|
||||||
//HomoEFieldItems Abarbeiten
|
//HomoEFieldItems Abarbeiten
|
||||||
if (qgraphicsitem_cast<HomoEFieldItem*> (items(point).at(i)) != 0) {
|
if (qgraphicsitem_cast<HomoEFieldItem*> (items(point).at(i)) != 0) {
|
||||||
@@ -550,6 +543,7 @@ double SimulScene::getMeterPerPx() const {
|
|||||||
void SimulScene::setMeterPerPx ( double theValue ) {
|
void SimulScene::setMeterPerPx ( double theValue ) {
|
||||||
if (theValue == meterPerPx) return;
|
if (theValue == meterPerPx) return;
|
||||||
meterPerPx = theValue;
|
meterPerPx = theValue;
|
||||||
|
emit meterPerPxChanged(theValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class HomoEFieldItem;
|
|||||||
class QGraphicsRectItem;
|
class QGraphicsRectItem;
|
||||||
class QGraphicsItemGroup;
|
class QGraphicsItemGroup;
|
||||||
class GraphicsEllipseItem;
|
class GraphicsEllipseItem;
|
||||||
|
class QGraphicsItemAnimation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@author Peter Dahlberg <pdahlberg@gmail.com>
|
@author Peter Dahlberg <pdahlberg@gmail.com>
|
||||||
@@ -49,7 +50,7 @@ class SimulScene : public QGraphicsScene {
|
|||||||
\param charge Die Ladung, auf die die Kraft ausgeübt wird
|
\param charge Die Ladung, auf die die Kraft ausgeübt wird
|
||||||
\param xy x oder y-Richtung
|
\param xy x oder y-Richtung
|
||||||
*/
|
*/
|
||||||
long double getPowerAt(QPointF point, long double charge, char xy);
|
double getPowerAt(QPointF point, double charge, char xy);
|
||||||
QWidget* getProbeDockWidget() const;
|
QWidget* getProbeDockWidget() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -74,6 +75,7 @@ class SimulScene : public QGraphicsScene {
|
|||||||
void sceneModeChanged(int mode);
|
void sceneModeChanged(int mode);
|
||||||
void stepsChanged(int steps);
|
void stepsChanged(int steps);
|
||||||
void timePerStepChanged(double timePerStep);
|
void timePerStepChanged(double timePerStep);
|
||||||
|
void meterPerPxChanged(double meterPerPx);
|
||||||
private:
|
private:
|
||||||
QTimeLine *timer;
|
QTimeLine *timer;
|
||||||
|
|
||||||
@@ -90,6 +92,7 @@ class SimulScene : public QGraphicsScene {
|
|||||||
QGraphicsItem *pressedResizeItem;
|
QGraphicsItem *pressedResizeItem;
|
||||||
|
|
||||||
GraphicsEllipseItem *ellipse1;
|
GraphicsEllipseItem *ellipse1;
|
||||||
|
QGraphicsItemAnimation *ani;
|
||||||
|
|
||||||
|
|
||||||
//rechtecke zur groesenaenderung
|
//rechtecke zur groesenaenderung
|
||||||
|
|||||||
Reference in New Issue
Block a user