Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of scoreLight_Advanced by
Diff: elasticLoop.h
- Revision:
- 1:a4050fee11f7
- Parent:
- 0:345b3bc7a0ea
- Child:
- 4:f9d364f10335
--- a/elasticLoop.h Wed Mar 28 14:40:01 2012 +0000
+++ b/elasticLoop.h Sat Mar 31 08:19:31 2012 +0000
@@ -21,9 +21,6 @@
//#define MAX_NUM_MASSES 50
//#define PI 3.1415926
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-#define max(a, b) (((a) > (b)) ? (a) : (b))
-
enum ElasticLoopMode {RELAX, CONTRACT, CONTRACT_CENTRAL, CONTOUR_FOLLOWING, CONTOUR_FOLLOWING_FAST, BOUNCING};
class elasticLoop : public soundSpot {
@@ -35,7 +32,7 @@
~elasticLoop();
// instantiation of the virtual methods of the base class (we don't need to append "virtual", but for clarity I do):
- virtual void createBlob(int _id, int _elasticBlobMode, vector2D _initPos);
+ void createBlob(int _id, ElasticLoopMode _elasticBlobMode, vector2D _initPos);
virtual void setRegionMotion(int mmix, int mmiy, int mmax, int mmay); // attention: initial position posX and posY should be inside this bounding box...
virtual void update(); // update dynamics of the mass loop
virtual void draw(void); // draw the blob (renders on the laser trajectory object lsdTrajectory from the base class, using the openGL laser renderer - not yet done).
@@ -47,10 +44,15 @@
void createLoopFromScafold(void);
void processLoopData(); // process elastic loop data
+ // ====================== VARIABLES ======================
+
+ //ElasticLoopMode loopMode;
+
// The loop of masses with springs:
- int numMasses;
+ int numMasses; // Number of particles in the elastic loop (this may or may not be equal to the number of points in the lsdTrajectory)
vector<pointMass> massesLoop;
vector<spring> loopSpringArray;
+ // NOTE: to save memory, we can drop hairVector (use lightForce instead, and then normalize it when required)
vector<vector2D> hairVector; // the perpendiculars to the loop
vector<vector2D> lightForce;
//vector2D totalLightForce; // this belongs to the base class now
@@ -58,13 +60,6 @@
// For the central anchor point:
pointMass anchorMass;
vector<spring> centralSpringArray;
-
- // ====================== VARIABLES ======================
- // Number of particles in the elastic loop (this may or may not be equal to the number of points in the lsdTrajectory)
- // int numMasses;
-
- // Meta-modes for the elastic loop:
- ElasticLoopMode loopMode;
// Detail modes (could be in a struct)
// Behaviour mode:
@@ -81,14 +76,15 @@
// Recentering vector (obtained by rotating the total light force by an arbitrary angle) for the anchor mass, and for each point in the loop
// ex: if it is 180deg, then the blob just "bounces" on the zone transition; if it is 90, it does contour following...
- float angleCorrectionForceLoop;
- float angleCorrectionForceNucleus;
-
- vector2D recenteringVectorNucleus;
- // the following are common to all blobs:
- // vector2D recenteringVectorLoop;
+
+ // The following are common to all blobs:
+ // float angleCorrectionForceLoop;
+ // vector2D recenteringVectorLoop;
// float angleRecenteringVector; // auxiliary variables for sending data (for the recenteringVectorLoop)
// float normRecenteringVector;
+
+ float angleCorrectionForceNucleus;
+ vector2D recenteringVectorNucleus;
// Numeric parameters:
float massLoopParticle;
@@ -103,7 +99,7 @@
float factorRecenteringLoopMass;
float factorPressureLoopMass;
float factorForceBorder;
- float interParticleRange, factorInterParticleForce; // zach like blob force
+ float interParticleRange, factorInterParticleForce; // zach like blob force
// SOUND SENDING MODES (specific to this kind of blob object):
/*
