-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrapezoid.cpp
129 lines (125 loc) · 2.43 KB
/
trapezoid.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
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
//#include "trapezoid.hpp"
#include "config.hpp"
#include <stdio.h>
void Trapezoid(void (*func)(float),float max_value,unsigned int delay_time){
double value;
if(func==NULL){
printf("func NULL\n");
return;
}
if(max_value<0.15){
printf("max_value low\n");
return;
}else if(max_value<0.3){
for(value = 0.1;value<max_value;value+=0.0003){
(*func)(value);
}
delay(delay_time);
for(;value>0.1;value-=0.0003){
(*func)(value);
}
(*func)(0);
}else{
for(value = 0.1;value<0.3;value+=0.0006){
(*func)(value);
}
for(;value<max_value-0.2;value+=0.0027){
(*func)(value);
}
for(;value<max_value;value+=0.0006){
(*func)(value);
}
delay(delay_time);
for(;value>max_value-0.2;value-=0.0006){
(*func)(value);
}
for(;value>0.3;value-=0.0027){
(*func)(value);
}
for(;value>0.1;value-=0.0006){
(*func)(value);
}
(*func)(0);
}
printf("daikei\n");
}
void Trapezoid_fh(void (*func)(float),float max_value){
double value;
if(func==NULL){
printf("func NULL\n");
return;
}
if(max_value<0.15){
printf("max_value low\n");
return;
}else if(max_value<0.3){
for(value = 0.1;value<max_value;value+=0.0003){
(*func)(value);
}
}else{
for(value = 0.1;value<0.3;value+=0.0006){
(*func)(value);
}
for(;value<max_value-0.2;value+=0.0027){
(*func)(value);
}
for(;value<max_value;value+=0.0006){
(*func)(value);
}
}
printf("daikei_fh\n");
}
void Trapezoid_sh(void (*func)(float),float max_value){
double value;
if(func==NULL){
printf("func NULL\n");
return;
}
if(max_value<0.15){
printf("max_value low\n");
return;
}else if(max_value<0.3){
for(value=max_value;value>0.0;value-=0.0003){
(*func)(value);
}
(*func)(0);
}else{
for(value=max_value;value>max_value-0.2;value-=0.0006){
(*func)(value);
}
for(;value>0.3;value-=0.0027){
(*func)(value);
}
for(;value>0.1;value-=0.0006){
(*func)(value);
}
(*func)(0);
}
printf("daikei_sh\n");
}
void Trapezoid_sp(void (*func)(float),float max_value){
double value;
if(func==NULL){
printf("func NULL\n");
return;
}
if(max_value<0.15){
printf("max_value low\n");
return;
}else if(max_value<0.3){
for(value=max_value;value>0.15;value-=0.0003){
(*func)(value);
}
}else{
for(value=max_value;value>max_value-0.2;value-=0.0006){
(*func)(value);
}
for(;value>0.3;value-=0.0027){
(*func)(value);
}
for(;value>0.15;value-=0.0006){
(*func)(value);
}
}
printf("daikei_sp\n");
}