-
Notifications
You must be signed in to change notification settings - Fork 2
/
Friction.h
272 lines (240 loc) · 10.9 KB
/
Friction.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
//
// Created by Ryan.Zurrin001 on 12/16/2021.
//
#ifndef PHYSICSFORMULA_FRICTION_H
#define PHYSICSFORMULA_FRICTION_H
#include <iostream>
#include <cmath>
#include "Constants.h"
// class for doing physics problems
// author: Ryan Zurrin
// last Modified: 10/11/2020
//static object counter for class
static int friction_objectCount = 0;
// static friction coefficients
static struct FrictionCoefficient
{
struct StaticCoefficient
{
const ld rubber_on_concrete_dry = 1.0;//returns 1.0
const ld rubber_on_concrete_wet = .7; //returns 0.7
const ld wood_on_wood = .5; //returns 0.5
const ld waxedWood_on_wetSnow = .14; //returns 0.14
const ld metal_on_wood = .5; //returns 0.5
const ld steel_on_steel_dry = .6; //returns 0.6
const ld steel_on_steel_oiled = .05; //returns 0.05
const ld teflon_on_steel = .04; //returns 0.04
const ld bone_on_lubricated_synovial_fluid = .016; //returns 0.016
const ld shoes_on_wood = .9; //returns 0.9
const ld shoes_on_ice = .1; //returns 0.1
const ld ice_on_ice = .1; //returns 0.1
const ld steel_on_ice = 0.4; // returns 0.4
}staticFriction;
// Kinetic friction coefficients
struct KineticCoefficient
{
const ld rubber_on_concrete_dry = .7; //returns 0.7
const ld rubber_on_concrete_wet = .5; //returns 0.5
const ld wood_on_wood = .3; //return 0.3
const ld waxedWood_on_wetSnow = .1;//return 0.1
const ld metal_on_wood = .3; //returns 0.3
const ld steel_on_steel_dry = .3; //returns 0.3
const ld steel_on_steel_oiled = .03; //return 0.03
const ld teflon_on_steel = .4; //return 0.4
const ld bone_on_lubricated_synovial_fluid = .015; //returns 0.015
const ld shoes_on_wood = .5; //returns 0.5
const ld shoes_on_ice = .5; //return 0.5
const ld ice_on_ice = .03; //return 0.03
const ld steel_on_ice = .04; // return .04
}kineticFriction;
}friction;
class Friction
{
public:
static void countShow() { std::cout << "friction count: "
<< friction_objectCount << std::endl; }
void displayFrictionalCoefficients()const {
cout << "static coefficient: " << _staticCoefficient_ << endl;
cout << "kinetic coefficient: " << _kineticCoefficient_ << endl;
}
// constructor
Friction()
{
_staticCoefficient_ = 0.0;
_kineticCoefficient_ = 0.0;
countIncrease();
//countShow();
}
Friction(ld sc, ld kc)
{
_staticCoefficient_ = sc;
_kineticCoefficient_ = kc;
countIncrease();
}
// copy constructor
Friction(const Friction& f)
{
_staticCoefficient_ = f._staticCoefficient_;
_kineticCoefficient_ = f._kineticCoefficient_;
countIncrease();
//countShow();
}
/**
* Returns the calculated force of friction, which is the same as the force
* @param mass
* @param coefficient of friction
* @returns frictional force
*/
static ld friction_force(const ld mass, const ld coefficient)
{
return coefficient * mass * constants::Ga;
}
/**
* Returns the friction coefficient using the Normal Force and the Friction Force as known data
* @param normalForce is the amount of normal force found by multiplying mass(kg) * 9.8 (m/s^2)
* @param frictionForce is the amount of force the friction is pushing back against something.
* @returns the frictional coefficient of objects in question
*/
static ld friction_coefficient(const ld normalForce, const ld frictionForce)
{
return (frictionForce) / (normalForce);
}
/**
* Returns the acceleration of an object taking into account its mass and the frictional coefficient
* of the materials.
* @param mass in kg
* @param frictionCoefficient of the materials
* @returns magnitude of the acceleration of an object
*/
static ld acceleration_magnitude(const ld mass, const ld frictionCoefficient)
{
const ld normalForce = mass * constants::Ga;
const ld frictionForce = normalForce * frictionCoefficient;
return frictionForce / mass;
}
/**
* Returns the initial velocity when giving the amount of time it takes something
* to come to a stop
* @param mass of object in kg
* @param frictionCoefficient for the materials in consideration
* @param time in seconds it took to come to a stop
* @returns initial velocity
*/
static ld initial_velocity(const ld mass, const ld frictionCoefficient, const ld time)
{
const ld normalForce = mass * constants::Ga;
const ld frictionForce = normalForce * frictionCoefficient;
const ld acceleration = frictionForce / mass;
return acceleration * time;
}
/**
* method: acceleration_slope_friction(const ld angleTheta, const ld kineticCoefficient)
* arguments: 1)angleTheta 2)kineticCoefficient
* purpose: calculates the normal force on an angle
* returns: ld, normal force
*/
static ld acceleration_down_slope_friction(const ld angleTheta, const ld kineticCoefficient)
{
return constants::Ga * (sin(angleTheta * constants::RADIAN) - (kineticCoefficient * cos(angleTheta * constants::RADIAN)));
}
/**
* method: acceleration_up_slope_friction(const ld angleTheta, const ld frictionalCoefficient)
* arguments: 1)angleTheta 2)frictionalCoefficient
* purpose: calculates the acceleration of an object going up a slope, like a 4 wheel drive car
* returns: ld, acceleration
*/
static ld acceleration_up_slope_friction(const ld angleTheta, const ld frictionalCoefficient)
{
return constants::Ga * ((frictionalCoefficient*cos(angleTheta * constants::RADIAN) - sin(angleTheta*constants::RADIAN)));
}
/**
* method: car2wheel_acceleration_up_slope_friction(const ld angleTheta, const ld kineticCoefficient)
* arguments: 1)angleTheta 2)kineticCoefficient
* purpose: calculates the normal force on an angle
* returns: ld, normal force
*/
static ld car2wheel_acceleration_up_slope_friction(const ld angleTheta, const ld kineticCoefficient)
{
return constants::Ga * ((kineticCoefficient*cos(angleTheta*constants::RADIAN)/2)-(sin(angleTheta * constants::RADIAN)));
}
/**
* method: tension_rope_rockClimber(const ld angleRope, const ld angleLegs, const ld mass)
* arguments: 1)angleRope 2)angleLegs 3)mass
* purpose: calculates the tension on a rope from a hanging rock climber or similar situation
* returns: ld, tension force
*/
static ld tension_rope_rockClimber(const ld angleRope, const ld angleLegs, const ld mass)
{
return (mass * constants::Ga) / (cos(angleRope*constants::RADIAN) + sin(angleRope*constants::RADIAN) * tan(angleLegs*constants::RADIAN));
}
/**
* method: tension_legs_rockClimber(const ld angleRope, const ld angleLegs, const ld mass)
* arguments: 1)angleRope 2)angleLegs 3)mass
* purpose: calculates the tension on a rope from a hanging rock climber or similar situation
* returns: ld, tension force on legs
*/
static ld tension_legs_rockClimber(const ld angleRope, const ld angleLegs, const ld mass)
{
return (tension_rope_rockClimber(angleRope, angleLegs, mass)*sin(angleRope*constants::RADIAN)/cos(angleLegs*constants::RADIAN));
}
/**
* method: minimum_force_start_move_push(const ld mass, const ld pushAngle, const ld frictionCoefficient)
* arguments: 1)mass 2)pushAngle 3)frictionCoefficient
* purpose: calculates the minimum force it takes to start moving an object pushing at a downward angle
* returns: ld, minimum force to start moving block
*/
static ld minimum_force_start_move_downPush(const ld mass, const ld pushAngle, const ld staticCoefficient)
{
return (staticCoefficient * mass*constants::Ga) / (cos(pushAngle*constants::RADIAN)- staticCoefficient * sin(pushAngle*constants::RADIAN));
}
/**
* method: magnitude_acceleration_moving_object_downPush(const ld mass, const ld pushAngle, const ld frictionCoefficient)
* arguments: 1)mass 2)pushAngle 3)frictionCoefficient
* purpose: calculates the acceleration of the object once it starts moving if force is maintained
* returns: ld, acceleration
*/
static ld magnitude_acceleration_moving_object_downPush(const ld mass, const ld pushAngle, const ld kineticCoefficient, const ld staticCoefficient)
{
return ((minimum_force_start_move_downPush(mass, pushAngle, staticCoefficient) * cos(pushAngle*constants::RADIAN) - kineticCoefficient *sin(pushAngle*constants::RADIAN))-(kineticCoefficient)*mass*constants::Ga)/(mass);
}
/**
* method: minimum_force_start_move_upPull(const ld mass, const ld pullAngle, const static ldCoefficient)
* arguments: 1)mass 2)pushAngle 3)frictionCoefficient
* purpose: calculates the minimum force it takes to start moving an object pulling on it upward by a rope
* returns: ld, minimum force to start moving block fro pulling up
*/
static ld minimum_force_start_move_upPull(const ld mass, const ld pullAngle, const ld staticCoefficient)
{
return (staticCoefficient*mass*constants::Ga)/(cos(pullAngle*constants::RADIAN) + staticCoefficient*sin(pullAngle*constants::RADIAN));
}
/**
* method: magnitude_acceleration_moving_object_pullingUp(const ld mass, const ld pullAngle, const ld kineticCoefficient)
* arguments: 1)mass 2)pushAngle 3)frictionCoefficient
* purpose: calculates the minimum force it takes to start moving an object pulling on it upward by a rope
* returns: ld, minimum force to start moving block fro pulling up
*/
static ld magnitude_acceleration_moving_object_pullingUp(const ld mass, const ld pullAngle, const ld kineticCoefficient, const ld maintainingForce)
{
ld a, b;
a = maintainingForce * cos(pullAngle * constants::RADIAN);
b = kineticCoefficient * ((mass * constants::Ga) - maintainingForce * sin(pullAngle * constants::RADIAN));
return (a-b)/(mass);
}
void setKineticCoefficient(ld val) { _kineticCoefficient_ = val; }
void setStaticCoefficient(ld val) { _staticCoefficient_ = val; }
ld staticCoefficient() { return _staticCoefficient_; }
ld kineticCoefficient() { return _kineticCoefficient_; }
// destructor
~Friction()
{
countDecrease();
//countShow();
}
private:
ld _kineticCoefficient_;
ld _staticCoefficient_;
map<string, double> frictionCoeffMap;
static void countIncrease() { friction_objectCount += 1; }
static void countDecrease() { friction_objectCount -= 1; }
};
#endif //PHYSICSFORMULA_FRICTION_H