-
Notifications
You must be signed in to change notification settings - Fork 0
/
buttomBlock.cpp
57 lines (47 loc) · 1.42 KB
/
buttomBlock.cpp
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
#include "stdafx.h"
#include<fstream>
#include<iostream>
#include<vector>
#include<array>
#include <memory>
#include "Block.h"
#include "buttomBlock.h"
using namespace std;
const int BblockHeight = 4;
const int BblockWidth = 4;
const int BnumBlocks = BblockHeight*BblockWidth;
double Bdt = 1e-7;
double Bk = 2.3e6; // Stiffness between blocks
double BL = 0.14; // Physical length of block chain
double Bd = BL / (BnumBlocks - 1); // Distance between blocks in block chain
double BM = 0.12;
double Bm = BM / BnumBlocks;
buttom_block::buttom_block()
{
type = blockType::buttom;
this->connectConnectors();
}
void buttom_block::connectConnectors()
{
for (int i = 1; i <= numberOfConnectors; i++)
{
double pos = this->xPos + i*connectorInterval;
this->connectors.push_back(shared_ptr<connector>(new connector(pos, Bdt)));
}
}
void buttom_block::calculateForces()
{
this->InternalForces();
for each (shared_ptr<connector> connect in connectors)
{
//this->xForce += connect->returnedForce(this->xPos,this->yPos,this->xVel);
//cout << connect->returnedForce(this->xPos, this->yPos, this->xVel) << endl;
//cout << this->xPos << endl;
xForce += connect->calulateConnectorForce(this->xPos, this->yPos, this->xVel);
//cout << connect->calulateConnectorForce(this->xPos, this->yPos, this->xVel) << endl;
}
}
bool buttom_block::returnState()
{
return connectors[0]->state;
}