annotate lump.h @ 5:085d80989ba7

Release 1.01
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 10 Dec 2012 16:20:57 +0000
parents 79c7cf39a0a0
children 4ea605899aca
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@4 21
rt300@0 22 TwoVector velocity;
rt300@0 23 TwoVector accel;
rt300@0 24 double friction;
rt300@0 25
rt300@0 26 public:
rt300@0 27 bool constrained;
rt300@4 28 vector<Spring*> attachedSprings; // pointers to all attached springs
rt300@0 29 int numAttachedSprings;
rt300@0 30
rt300@0 31 enum ConstrainMode {NOT_CONSTRAINED,CONSTRAIN_X,CONSTRAIN_Y,CONSTRAIN_XY};
rt300@0 32 ConstrainMode constrainMode;
rt300@0 33
rt300@0 34 bool isInScanPath;
rt300@4 35 bool isScanPathEnd;
rt300@4 36 bool isScanPathStart;
rt300@4 37
rt300@0 38 TwoVector position;
rt300@0 39 TwoVector previousPosition;
rt300@0 40 double totalForceMag;
rt300@0 41 double size;
rt300@0 42 int grabID; // which touch is this lump grabbed by?
rt300@0 43
rt300@0 44 Lump(); // default constructor
rt300@0 45 Lump(double aMass,double aFriction, double positionX, double positionY);
rt300@0 46 // also which spring is it attached to
rt300@0 47 ~Lump();
rt300@5 48 double radialDisplacement;
rt300@0 49 TwoVector applyForce();
rt300@0 50 void averagingFilter(double amt);
rt300@0 51 void homingFilter(double amt);
rt300@0 52 TwoVector averageOfConnected();
rt300@0 53
rt300@0 54 TwoVector zeroRefPos;
rt300@0 55 void draw();
rt300@0 56
rt300@0 57 void attachSpring(Spring* aSpring);
rt300@0 58 void setPosition(double ax, double ay);
rt300@0 59 void setVelocity(double ax, double ay);
rt300@0 60 void constrain();
rt300@0 61 void constrain(ConstrainMode aconstrainMode);
rt300@0 62 void unconstrain();
rt300@0 63
rt300@0 64 bool isGrabbed();
rt300@0 65 void grab(int aGrabID);
rt300@0 66 void drag(double ax, double ay, int aGrabID);
rt300@0 67 void unGrab();
rt300@0 68 void highlight();
rt300@0 69 void unhighlight();
rt300@0 70 void setInvMass(double aInvMass);
rt300@0 71 double getTotalForceMag();
rt300@0 72 void setZeroRefPos();
rt300@0 73 void setFriction(double aF);
rt300@0 74
rt300@0 75 Spring * checkConnectedTo(Lump * otherLump);
rt300@0 76
rt300@0 77 // interface to scan path
rt300@0 78 double scanDisplacement();
rt300@0 79 double scanRadialDisplacement();
rt300@0 80 double scanLumpSpeed();
rt300@0 81 double scanYPos();
rt300@0 82 double scanXPos();
rt300@0 83 void addToScanPath();
rt300@0 84 void removeFromScanPath();
rt300@0 85
rt300@0 86 };
rt300@0 87
rt300@0 88 #endif