annotate lump.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 79c7cf39a0a0
rev   line source
rt300@0 1 /*
rt300@0 2 * lump.h
rt300@0 3 * simplespring
rt300@0 4 *
rt300@0 5 * Created by Robert Tubb on 01/06/2011.
rt300@0 6 * Copyright 2011 __MyCompanyName__. All rights reserved.
rt300@0 7 *
rt300@0 8 */
rt300@0 9 #ifndef _LUMPH
rt300@0 10 #define _LUMPH
rt300@0 11 #include "2dvector.h"
rt300@0 12 #include "ofMain.h"
rt300@0 13 #include "spring.h"
rt300@0 14
rt300@0 15
rt300@0 16 class Spring;
rt300@0 17 class Lump {
rt300@0 18 private:
rt300@0 19 double mass, inverseMass;
rt300@0 20 bool grabbed, highlighted;
rt300@0 21 const int maxSprings;
rt300@0 22
rt300@0 23 TwoVector velocity;
rt300@0 24 TwoVector accel;
rt300@0 25 double friction;
rt300@0 26
rt300@0 27 public:
rt300@0 28 bool constrained;
rt300@0 29 Spring** attachedSprings; // pointers to all attached springs
rt300@0 30 int numAttachedSprings;
rt300@0 31
rt300@0 32 enum ConstrainMode {NOT_CONSTRAINED,CONSTRAIN_X,CONSTRAIN_Y,CONSTRAIN_XY};
rt300@0 33 ConstrainMode constrainMode;
rt300@0 34
rt300@0 35 bool isInScanPath;
rt300@0 36
rt300@0 37 TwoVector position;
rt300@0 38 TwoVector previousPosition;
rt300@0 39 double totalForceMag;
rt300@0 40 double size;
rt300@0 41 int grabID; // which touch is this lump grabbed by?
rt300@0 42
rt300@0 43 Lump(); // default constructor
rt300@0 44 Lump(double aMass,double aFriction, double positionX, double positionY);
rt300@0 45 // also which spring is it attached to
rt300@0 46 ~Lump();
rt300@0 47
rt300@0 48 TwoVector applyForce();
rt300@0 49 void averagingFilter(double amt);
rt300@0 50 void homingFilter(double amt);
rt300@0 51 TwoVector averageOfConnected();
rt300@0 52
rt300@0 53 TwoVector zeroRefPos;
rt300@0 54 void draw();
rt300@0 55
rt300@0 56 void attachSpring(Spring* aSpring);
rt300@0 57 void setPosition(double ax, double ay);
rt300@0 58 void setVelocity(double ax, double ay);
rt300@0 59 void constrain();
rt300@0 60 void constrain(ConstrainMode aconstrainMode);
rt300@0 61 void unconstrain();
rt300@0 62
rt300@0 63 bool isGrabbed();
rt300@0 64 void grab(int aGrabID);
rt300@0 65 void drag(double ax, double ay, int aGrabID);
rt300@0 66 void unGrab();
rt300@0 67 void highlight();
rt300@0 68 void unhighlight();
rt300@0 69 void setInvMass(double aInvMass);
rt300@0 70 double getTotalForceMag();
rt300@0 71 void setZeroRefPos();
rt300@0 72 void setFriction(double aF);
rt300@0 73
rt300@0 74 Spring * checkConnectedTo(Lump * otherLump);
rt300@0 75
rt300@0 76 // interface to scan path
rt300@0 77 double scanDisplacement();
rt300@0 78 double scanRadialDisplacement();
rt300@0 79 double scanLumpSpeed();
rt300@0 80 double scanYPos();
rt300@0 81 double scanXPos();
rt300@0 82 void addToScanPath();
rt300@0 83 void removeFromScanPath();
rt300@0 84
rt300@0 85 };
rt300@0 86
rt300@0 87 #endif