view 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
line wrap: on
line source
/*
 *  spring.h
 *  simplespring
 *
 *  Created by Robert Tubb on 02/06/2011.
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
 *
 */



#ifndef _SPRINGH
#define _SPRINGH
#include "2dvector.h"
#include "ofMain.h"

class Lump;

class Spring{
protected:
	double restLength;
	double springConst;
	
	static double maxForce;
	static double minForce;
	
	static int numSprings;

	int myIndex;
    
    double csquared;
	
	TwoVector startPoint;
	TwoVector endPoint;
	
	TwoVector force;
	Lump * startLumpPtr;
	Lump * endLumpPtr;
	
	

	
public:
    bool isInScanPath;
	static bool forcesOn;
	int myIndexInMesh;
	Spring();
	Spring(double aStartx, double aStarty, double aEndx, double aEndy, double aK);
	void updateEndPoints();
	void attachLump(Lump * aLump);
    
    void calculateForce();
    virtual TwoVector getForce(Lump * aLump);

	void draw();
	void setRestLength();
	void setRestLength(double aLength);
    void setSpringConstant(double aK);
    double getLength();

	void addToScanPath();
    void removeFromScanPath();
    Lump * getLumpOnOtherEnd(Lump * alump);
    Lump * getStartLump();
    Lump * getEndLump();
    int getStartLumpIndex();
    int getEndLumpIndex();
	//void checkStuff();
    
    // interface for scanner
	double getForceMag();
};

class PressureSpring : public Spring{
public:
    PressureSpring();
    TwoVector getForce(Lump * aLump);

};

#endif