rt300@0: /* rt300@0: * spring.h rt300@0: * simplespring rt300@0: * rt300@0: * Created by Robert Tubb on 02/06/2011. rt300@0: * Copyright 2011 __MyCompanyName__. All rights reserved. rt300@0: * rt300@0: */ rt300@0: rt300@0: rt300@0: rt300@0: #ifndef _SPRINGH rt300@0: #define _SPRINGH rt300@0: #include "2dvector.h" rt300@0: #include "ofMain.h" rt300@0: rt300@0: class Lump; rt300@0: rt300@0: class Spring{ rt300@0: protected: rt300@0: double restLength; rt300@0: double springConst; rt300@0: rt300@0: static double maxForce; rt300@0: static double minForce; rt300@0: rt300@0: static int numSprings; rt300@0: rt300@0: int myIndex; rt300@0: rt300@0: double csquared; rt300@0: rt300@0: TwoVector startPoint; rt300@0: TwoVector endPoint; rt300@0: rt300@0: TwoVector force; rt300@0: Lump * startLumpPtr; rt300@0: Lump * endLumpPtr; rt300@0: rt300@3: rt300@0: rt300@0: rt300@0: public: rt300@3: bool isInScanPath; rt300@0: static bool forcesOn; rt300@9: int myIndexInMesh; rt300@0: Spring(); rt300@0: Spring(double aStartx, double aStarty, double aEndx, double aEndy, double aK); rt300@0: void updateEndPoints(); rt300@0: void attachLump(Lump * aLump); rt300@0: rt300@0: void calculateForce(); rt300@0: virtual TwoVector getForce(Lump * aLump); rt300@0: rt300@0: void draw(); rt300@0: void setRestLength(); rt300@0: void setRestLength(double aLength); rt300@0: void setSpringConstant(double aK); rt300@0: double getLength(); rt300@0: rt300@0: void addToScanPath(); rt300@0: void removeFromScanPath(); rt300@0: Lump * getLumpOnOtherEnd(Lump * alump); rt300@9: Lump * getStartLump(); rt300@9: Lump * getEndLump(); rt300@9: int getStartLumpIndex(); rt300@9: int getEndLumpIndex(); rt300@0: //void checkStuff(); rt300@0: rt300@0: // interface for scanner rt300@0: double getForceMag(); rt300@0: }; rt300@0: rt300@0: class PressureSpring : public Spring{ rt300@0: public: rt300@0: PressureSpring(); rt300@0: TwoVector getForce(Lump * aLump); rt300@0: rt300@0: }; rt300@0: rt300@0: #endif rt300@0: rt300@0: