-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmisc_utils.py
47 lines (37 loc) · 1.27 KB
/
misc_utils.py
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
#
# Open-BLDC pysim - Open BrushLess DC Motor Controller python simulator
# Copyright (C) 2011 by Antoine Drouin <[email protected]>
# Copyright (C) 2011 by Piotr Esden-Tempski <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import math
#
def rad_of_deg(d): return d/180.*math.pi
#
def deg_of_rad(r): return r*180./math.pi
#
def rpm_of_radps(rps): return rps/(2*math.pi)*60
#
def degps_of_radps(rps): return rps/(2*math.pi)*60*360
#
def radps_of_rpm(rpm): return rpm*(2*math.pi)/60
#
def vpradps_of_rpmpv(vprpm): return 30/(vprpm*math.pi)
#
def norm_angle(alpha):
alpha_n = math.fmod(alpha, 2*math.pi)
if alpha_n < 0.:
alpha_n = (2*math.pi) + alpha_n
return alpha_n