-
Notifications
You must be signed in to change notification settings - Fork 0
/
source.cpp
141 lines (118 loc) · 2.4 KB
/
source.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
130
131
132
133
134
135
136
137
138
139
140
141
#include "source.h"
#include <cmath>
#include <iostream>
using namespace std;
#define M_PI 3.14159265358979323846
source :: source(){
V_0 = 0;
phi = 0;
}
periodique::periodique(){
P=0;
}
non_periodique :: non_periodique(){
}
sinus :: sinus(){
}
sinus :: sinus(float saisie_V_0,float saisie_phi,float saisie_P){
V_0 = saisie_V_0;
phi = saisie_phi;
P = saisie_P;
}
float sinus :: Ve(float t){
return V_0*sin(2*(M_PI)*t/P+phi);
}
triangulaire :: triangulaire(){
}
triangulaire :: triangulaire(float m_V_0, float m_P, float m_phi){
V_0 = m_V_0;
P = m_P;
phi = m_phi;
}
float triangulaire :: Ve(float t){
while (t >=P){
t = t - P;
}
float a; //pente () utilisee pour le calcul du point Ve(0), on prends pour les calculs une pente positive)
a = 2.*V_0/P;
if (phi <= P/2.){
if (t <= phi){
return a * (phi - t);
}
else if (phi <= t && t <= (P/2.+phi)){
return a*(t - phi);
}
else if ((P/2.+phi) <= t && t <= (P+phi)){
return V_0 - a* (t - P/2. - phi);
}
}
else{
if (t <= (phi - P/2.)){
return (P-phi+t)*a;
}
else if ((phi - (P/2.)) <= t && t <= phi){
return V_0 -a*(t - phi + P/2.);
}
else if (phi <= t && t <= P){
return a*(t - phi);
}
}
return 0.0;
}
rectangulaire :: rectangulaire(){
T = 0;
}
rectangulaire :: rectangulaire(float m_V_0, float m_T, float m_phi, float m_P){
V_0 = m_V_0;
T = m_T;
phi = m_phi;
P = m_P;
}
float rectangulaire :: Ve(float t){
while (t >= P){
t = t - P;
}
if (t < phi) {
return 0.0;
}
else if (t < phi + T) {
return V_0;
}
else if (t <= P) {
return 0.0;
}
return 0.0;
}
creneau :: creneau(){
T = 0;
}
creneau :: creneau(float m_V_0, float m_T, float m_phi){
V_0 = m_V_0;
T = m_T;
phi = m_phi;
}
float creneau :: Ve(float t){
if (t < phi){
return 0;
}
else if ((phi < t) && (t < T + phi)){
return V_0;
}
else{
return 0.0;
}
}
step :: step(){
}
step :: step(float m_V_0,float m_phi){
phi = m_phi;
V_0 = m_V_0;
}
float step :: Ve(float t){
if (t <= phi){
return 0.0;
}
else{
return V_0;
}
}