Commit 39dd5449 authored by Jeff Niu's avatar Jeff Niu

PR comment changes

parent 89c808ec
......@@ -10,7 +10,7 @@
RenderScene::RenderScene(std::shared_ptr<Simulator> simulator, QWidget *parent)
: QOpenGLWidget(parent),
m_simulator(std::move(simulator)),
m_sam(this, MU_sf, 1e-3f, 0.01f) {
m_sam(this, MU_SF, 1e-3f, 0.01f) {
m_elapsed = 0;
setAutoFillBackground(false);
......@@ -66,7 +66,7 @@ const std::vector<Solenoid> *RenderScene::solenoids() const {
return &m_solenoids;
}
const Sam *RenderScene::sam() const {
const SAMRobot *RenderScene::sam() const {
return &m_sam;
}
......
......@@ -65,7 +65,7 @@ public:
/**
* @return a pointer to the Sam instance.
*/
const Sam *sam() const override;
const SAMRobot *sam() const override;
/**
* Start the ticker.
......@@ -98,7 +98,7 @@ private:
/**
* Object representing the location of SAM.
*/
Sam m_sam;
SAMRobot m_sam;
};
......
......@@ -2,16 +2,16 @@
#define MINOTAUR_CPP_RENDERSCENEBASE_H
// Magnetic permeability of free space
#define MU_0f ((float) M_PI * 4e-7f)
#define MU_0F ((float) M_PI * 4e-7f)
// Coefficient of static friction
#define MU_sf 1.0f
#define MU_SF 1.0f
// Gravitational field strength
#define gf 9.809f
#define G_FIELD 9.809f
#include "drawable.h"
class Solenoid;
class Sam;
class SAMRobot;
/**
* Base render scene referenced by Drawables to
......@@ -23,7 +23,7 @@ public:
virtual vector2f center() const = 0;
virtual const std::vector<Solenoid> *solenoids() const = 0;
virtual const Sam *sam() const = 0;
virtual const SAMRobot *sam() const = 0;
};
#endif //MINOTAUR_CPP_RENDERSCENEBASE_H
#include "sam.h"
#include "solenoid.h"
Sam::Sam(RenderSceneBase *scene, float mu_s, float mass, float length)
SAMRobot::SAMRobot(RenderSceneBase *scene, float mu_s, float mass, float length)
: m_renderScene(scene),
m_fric(mu_s),
m_mass(mass),
......@@ -10,7 +10,7 @@ Sam::Sam(RenderSceneBase *scene, float mu_s, float mass, float length)
m_vel(0, 0) {
}
void Sam::draw(QPainter *painter, QPaintEvent *, int elapsed, float scale) {
void SAMRobot::draw(QPainter *painter, QPaintEvent *, int elapsed, float scale) {
// Update phase
float dt = elapsed / 1000.0f;
const std::vector<Solenoid> *solenoids = m_renderScene->solenoids();
......@@ -21,7 +21,7 @@ void Sam::draw(QPainter *painter, QPaintEvent *, int elapsed, float scale) {
}
float vel = hypotf(m_vel.x(), m_vel.y());
if (vel > 0) {
float sfric = gf * m_mass * m_fric;
float sfric = G_FIELD * m_mass * m_fric;
vector2f vfric(-sfric * m_vel.x() / vel, -sfric * m_vel.y() / vel);
bool xdir = m_vel.x() > 0;
bool ydir = m_vel.y() > 0;
......@@ -55,27 +55,27 @@ void Sam::draw(QPainter *painter, QPaintEvent *, int elapsed, float scale) {
painter->drawPolygon(vertices, 4);
}
const typename Sam::vector2f &
Sam::pos() const {
const typename SAMRobot::vector2f &
SAMRobot::pos() const {
return m_pos;
}
const typename Sam::vector2f &
Sam::vel() const {
const typename SAMRobot::vector2f &
SAMRobot::vel() const {
return m_vel;
}
const typename Sam::vector2f &
Sam::mag() const {
const typename SAMRobot::vector2f &
SAMRobot::mag() const {
return m_mag;
}
void Sam::stop() {
void SAMRobot::stop() {
m_vel.setX(0);
m_vel.setY(0);
}
void Sam::reset() {
void SAMRobot::reset() {
m_pos.setX(0);
m_pos.setY(0);
stop();
......
......@@ -8,7 +8,7 @@
* This class represents SAM, a robot with an orientation and
* position in the field.
*/
class Sam : public Drawable {
class SAMRobot : public Drawable {
public:
/**
* Create an instance of SAM.
......@@ -18,7 +18,7 @@ public:
* @param mass the mass of SAM
* @param length the length of SAM (in meters), which is shaped as a square
*/
explicit Sam(RenderSceneBase *scene, float mu_s, float mass, float length);
explicit SAMRobot(RenderSceneBase *scene, float mu_s, float mass, float length);
/**
* Draw SAM.
......
......@@ -50,7 +50,7 @@ void Solenoid::draw(QPainter *painter, QPaintEvent *, int, float scale) {
typename Solenoid::vector2f
Solenoid::fieldAt(const vector2f &Q) const {
vector2f Qp = rotate(translate(Q, m_pos), -m_theta);
float k = MU_0f * m_mu * m_I * m_N * powf(m_radius, 2.0f) / 4.0f;
float k = MU_0F * m_mu * m_I * m_N * powf(m_radius, 2.0f) / 4.0f;
float l2 = m_len / 2.0f;
float yp1 = Qp.y() - l2;
float yp2 = Qp.y() + l2;
......
......@@ -8,7 +8,7 @@ StatsDisplay::StatsDisplay(RenderSceneBase *render_scene)
void StatsDisplay::draw(QPainter *painter, QPaintEvent *, int, float) {
QString pos, vel, mag;
const Sam *sam = m_render_scene->sam();
const SAMRobot *sam = m_render_scene->sam();
char format[] = "(%.3g, %.3g)";
pos.sprintf(format, sam->pos().x(), sam->pos().y());
vel.sprintf(format, sam->vel().x(), sam->vel().y());
......
#ifndef MINOTAUR_CPP_STATISDISPLAY_H
#define MINOTAUR_CPP_STATISDISPLAY_H
#ifndef MINOTAUR_CPP_STATSDISPLAY_H
#define MINOTAUR_CPP_STATSDISPLAY_H
#include "drawable.h"
#include "renderscenebase.h"
......@@ -14,4 +14,4 @@ private:
RenderSceneBase *m_render_scene;
};
#endif //MINOTAUR_CPP_STATISDISPLAY_H
#endif //MINOTAUR_CPP_STATSDISPLAY_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment