-
Notifications
You must be signed in to change notification settings - Fork 0
/
Block.h
81 lines (64 loc) · 1.62 KB
/
Block.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#pragma once
#include "stdafx.h"
#include<fstream>
#include<iostream>
#include<vector>
#include<array>
#include <memory>
using namespace std;
/*
const int blockHeight = 4;
const int blockWidth = 4;
const int numBlocks = blockHeight*blockWidth;
double dt = 1e-7;
double nu = sqrt(0.1e3); //Dampning coefficient
double k = 2.3e6; // Stiffness between blocks
double L = 0.14; // Physical length of block chain
double d = L / (numBlocks - 1); // Distance between blocks in block chain
double M = 0.12;
double m = M / numBlocks;
*/
enum blockType
{
buttom = 0,
top = 1,
leftWall = 2,
rightWall = 3,
middle = 4,
buttomLeft = 5,
buttomRight = 6,
topLeft = 7,
topRight = 8
};
class block
{
public:
double xPos;
double yPos;
double xVel = 0;
double yVel = 0;
double xForce = 0;
double yForce = 0;
double springAttachmentPoint;
blockType type;
bool state = true;
double timeMelted = 0;
vector<shared_ptr<block>> neighbours;
vector<double> neighbourSpringConst;
int numberOfBlocks;
double blockL;
double blockM;
double blockd; // Distance between blocks in block chain
double blockm;
int xID;
int yID;
block();
void setData(double x, double y, const int numberOfBlocks_, double L_, double M_, int xID_, int yID_);
void fillNeigbours(vector<vector<shared_ptr<block>>> &blocks);
double springForce(double k, double d, double x, double y, int komponent);
double dampningForce(double nu, double vx, double vy, int komponent);
void InternalForces();
void integrate();
virtual void calculateForces();
virtual bool returnState();
};