Mercurial > hg > wabletios
annotate 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 |
rev | line source |
---|---|
rt300@0 | 1 /* |
rt300@0 | 2 * spring.h |
rt300@0 | 3 * simplespring |
rt300@0 | 4 * |
rt300@0 | 5 * Created by Robert Tubb on 02/06/2011. |
rt300@0 | 6 * Copyright 2011 __MyCompanyName__. All rights reserved. |
rt300@0 | 7 * |
rt300@0 | 8 */ |
rt300@0 | 9 |
rt300@0 | 10 |
rt300@0 | 11 |
rt300@0 | 12 #ifndef _SPRINGH |
rt300@0 | 13 #define _SPRINGH |
rt300@0 | 14 #include "2dvector.h" |
rt300@0 | 15 #include "ofMain.h" |
rt300@0 | 16 |
rt300@0 | 17 class Lump; |
rt300@0 | 18 |
rt300@0 | 19 class Spring{ |
rt300@0 | 20 protected: |
rt300@0 | 21 double restLength; |
rt300@0 | 22 double springConst; |
rt300@0 | 23 |
rt300@0 | 24 static double maxForce; |
rt300@0 | 25 static double minForce; |
rt300@0 | 26 |
rt300@0 | 27 static int numSprings; |
rt300@0 | 28 |
rt300@0 | 29 int myIndex; |
rt300@0 | 30 |
rt300@0 | 31 double csquared; |
rt300@0 | 32 |
rt300@0 | 33 TwoVector startPoint; |
rt300@0 | 34 TwoVector endPoint; |
rt300@0 | 35 |
rt300@0 | 36 TwoVector force; |
rt300@0 | 37 Lump * startLumpPtr; |
rt300@0 | 38 Lump * endLumpPtr; |
rt300@0 | 39 |
rt300@0 | 40 bool isInScanPath; |
rt300@0 | 41 |
rt300@0 | 42 |
rt300@0 | 43 public: |
rt300@0 | 44 static bool forcesOn; |
rt300@0 | 45 |
rt300@0 | 46 Spring(); |
rt300@0 | 47 Spring(double aStartx, double aStarty, double aEndx, double aEndy, double aK); |
rt300@0 | 48 void updateEndPoints(); |
rt300@0 | 49 void attachLump(Lump * aLump); |
rt300@0 | 50 |
rt300@0 | 51 void calculateForce(); |
rt300@0 | 52 virtual TwoVector getForce(Lump * aLump); |
rt300@0 | 53 |
rt300@0 | 54 void draw(); |
rt300@0 | 55 void setRestLength(); |
rt300@0 | 56 void setRestLength(double aLength); |
rt300@0 | 57 void setSpringConstant(double aK); |
rt300@0 | 58 double getLength(); |
rt300@0 | 59 |
rt300@0 | 60 void addToScanPath(); |
rt300@0 | 61 void removeFromScanPath(); |
rt300@0 | 62 Lump * getLumpOnOtherEnd(Lump * alump); |
rt300@0 | 63 //void checkStuff(); |
rt300@0 | 64 |
rt300@0 | 65 // interface for scanner |
rt300@0 | 66 double getForceMag(); |
rt300@0 | 67 }; |
rt300@0 | 68 |
rt300@0 | 69 class PressureSpring : public Spring{ |
rt300@0 | 70 public: |
rt300@0 | 71 PressureSpring(); |
rt300@0 | 72 TwoVector getForce(Lump * aLump); |
rt300@0 | 73 |
rt300@0 | 74 }; |
rt300@0 | 75 |
rt300@0 | 76 #endif |
rt300@0 | 77 |
rt300@0 | 78 |