Mercurial > hg > wabletios
diff spring.h @ 0:c667dfe12d47
OK. Ther real deal.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Mon, 19 Nov 2012 13:00:42 +0000 |
parents | |
children | d346ddc50f70 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spring.h Mon Nov 19 13:00:42 2012 +0000 @@ -0,0 +1,78 @@ +/* + * spring.h + * simplespring + * + * Created by Robert Tubb on 02/06/2011. + * Copyright 2011 __MyCompanyName__. All rights reserved. + * + */ + + + +#ifndef _SPRINGH +#define _SPRINGH +#include "2dvector.h" +#include "ofMain.h" + +class Lump; + +class Spring{ +protected: + double restLength; + double springConst; + + static double maxForce; + static double minForce; + + static int numSprings; + + int myIndex; + + double csquared; + + TwoVector startPoint; + TwoVector endPoint; + + TwoVector force; + Lump * startLumpPtr; + Lump * endLumpPtr; + + bool isInScanPath; + + +public: + static bool forcesOn; + + Spring(); + Spring(double aStartx, double aStarty, double aEndx, double aEndy, double aK); + void updateEndPoints(); + void attachLump(Lump * aLump); + + void calculateForce(); + virtual TwoVector getForce(Lump * aLump); + + void draw(); + void setRestLength(); + void setRestLength(double aLength); + void setSpringConstant(double aK); + double getLength(); + + void addToScanPath(); + void removeFromScanPath(); + Lump * getLumpOnOtherEnd(Lump * alump); + //void checkStuff(); + + // interface for scanner + double getForceMag(); +}; + +class PressureSpring : public Spring{ +public: + PressureSpring(); + TwoVector getForce(Lump * aLump); + +}; + +#endif + +