-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArm_data.cpp
More file actions
104 lines (94 loc) · 3.11 KB
/
Copy pathArm_data.cpp
File metadata and controls
104 lines (94 loc) · 3.11 KB
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
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include "Arm_data.h"
#include "Global_functions.H"
arm_specs::arm_specs()
{
base = 0.02; //m
height = 0.02; //m
radius = 0;
cross_area = 0.0004; //m^2
length = 0.5; //m
payload = 40; //kg
max_acc = 12; //rad/sec^2
}
arm_specs::arm_specs(double mass, double acc, double arm_length) //this constructor stores the input values from the user
{
payload = mass;
max_acc = acc;
length = arm_length;
}
void arm_specs::set_area_dim(double b, double h, double r) // this function is used to initialize the cross-section area dimensions
{
base = b;
height = h;
radius = r;
}
double arm_specs::area_calc(string area_type) // used to check if area is circle or rectangle, and calculate area
{
if(area_type == "circle")
{
double r;
cout<<"Please enter the radius(m): ";
cin>>r;
input_errors(r);
set_area_dim(0,0,r);
cout<<"Circle area= "<<(cross_area=M_PI*r*r)<<" m^2\n"; // used to initialize cross-section area ( if area is circle )
return cross_area;
}
else if (area_type == "rectangle")
{
double b,h;
cout <<"Please enter the base(m): ";
cin>>b;
input_errors(b);
cout<<"Please enter the height(m): ";
cin>>h;
input_errors(h);
set_area_dim(b,h,0);
cout<<"Rectangle area= "<<(cross_area=b*h)<<" m^2\n"; // used to initialize cross-section area ( if area is rectangle )
return cross_area;
}
}
double arm_specs::mod_area_calc(string area_type) // used to calculate area using modified dimensions during the optimization
{
if(area_type == "circle")
{
mod_cross_area=M_PI*modified_radius*modified_radius;
return mod_cross_area;
}
else if (area_type == "rectangle")
{
mod_cross_area=modified_base*modified_height;
return mod_cross_area;
}
}
double arm_specs::get_length(){return length;}
double arm_specs::get_mass(){return payload;}
double arm_specs::get_acc(){return max_acc;}
double arm_specs::get_area(){return cross_area;}
double arm_specs::get_base(){return base;}
double arm_specs::get_height(){return height;}
double arm_specs::get_radius(){return radius;}
double arm_specs::get_mod_base(){return modified_base;}
double arm_specs::get_mod_height(){return modified_height;}
double arm_specs::get_mod_radius(){return modified_radius;}
void arm_specs::set_mod_base( double b ) {modified_base =b;}
void arm_specs::set_mod_height( double h ) {modified_height =h;}
void arm_specs::set_mod_radius( double r ) {modified_radius = r;}
double arm_specs::get_mod_area () {return mod_cross_area;}
void arm_specs :: output_mod_data(string area_t) // used to output the new dimensions and the area after the optimization
{
if ( area_t == "rectangle" )
{
cout << "\nmodified base:" << get_mod_base() << " m\n";
cout << "modified height:" << get_mod_height() << " m\n";
}
if ( area_t == "circle" )
{
cout << "modified radius:" << get_mod_radius() << " m\n";
}
cout << "modified Area:" << get_mod_area() << " m^2\n";
}