annotate spring.h @ 15:d5758530a039 tip

oF0.84 Retina, and iPhone support
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Tue, 12 May 2015 15:48:52 +0100
parents 0e03760cf2d9
children
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@3 40
rt300@0 41
rt300@0 42
rt300@0 43 public:
rt300@3 44 bool isInScanPath;
rt300@0 45 static bool forcesOn;
rt300@9 46 int myIndexInMesh;
rt300@0 47 Spring();
rt300@0 48 Spring(double aStartx, double aStarty, double aEndx, double aEndy, double aK);
rt300@0 49 void updateEndPoints();
rt300@0 50 void attachLump(Lump * aLump);
rt300@0 51
rt300@0 52 void calculateForce();
rt300@0 53 virtual TwoVector getForce(Lump * aLump);
rt300@0 54
rt300@0 55 void draw();
rt300@0 56 void setRestLength();
rt300@0 57 void setRestLength(double aLength);
rt300@0 58 void setSpringConstant(double aK);
rt300@0 59 double getLength();
rt300@0 60
rt300@0 61 void addToScanPath();
rt300@0 62 void removeFromScanPath();
rt300@0 63 Lump * getLumpOnOtherEnd(Lump * alump);
rt300@9 64 Lump * getStartLump();
rt300@9 65 Lump * getEndLump();
rt300@9 66 int getStartLumpIndex();
rt300@9 67 int getEndLumpIndex();
rt300@0 68 //void checkStuff();
rt300@0 69
rt300@0 70 // interface for scanner
rt300@0 71 double getForceMag();
rt300@0 72 };
rt300@0 73
rt300@0 74 class PressureSpring : public Spring{
rt300@0 75 public:
rt300@0 76 PressureSpring();
rt300@0 77 TwoVector getForce(Lump * aLump);
rt300@0 78
rt300@0 79 };
rt300@0 80
rt300@0 81 #endif
rt300@0 82
rt300@0 83