-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangles.py
More file actions
112 lines (94 loc) · 2.77 KB
/
angles.py
File metadata and controls
112 lines (94 loc) · 2.77 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
104
105
106
107
108
109
110
111
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 2 16:29:29 2018
@author: elijah
"""
import os, math
import numpy as np
#from enum import Enum
"""
MEASURE
Velocity by default: m/s
Angle by default: degrees
"""
GRID = [ 300, 500, 1000, 3000, 5000, 10000 ]
"""
"""
def inlist(v):
if type(v) == list:
return v
return [v]
def outlist(v):
if len(v) == 1:
return v[0]
return v
class MPS:
def mps(value):
return value
def kmh(value):
return outlist([v*1000.0/3600.0 for v in inlist(value)])
def nod(value):
return outlist([v*1852.0/3600.0 for v in inlist(value)])
class KMH:
def kmh(value):
return value
def mps(value):
return outlist([v*3600.0/1000.0 for v in inlist(value)])
def nod(value):
return outlist([v*1.852 for v in inlist(value)])
class NOD:
def nod(value):
return value
def mps(value):
return outlist([v*3600.0/1852.0 for v in inlist(value)])
def kmh(value):
return outlist([v/1.852 for v in inlist(value)])
"""
"""
class RAD:
def rad(value):
return value
def degree(value):
return np.radians(value)
class DEGREE:
def degree(value):
return value
def rad(value):
return np.degrees(value)
"""
"""
# degrees per second
class DPS:
def __init__(self, radius):
self.radius = radius
def dps(self, value):
return value
def mps(self, value):
return outlist([v/(self.radius*math.pi/180.0) for v in inlist(value)])
def kmh(self, value):
return outlist([(v*1000/3600.0)/(self.radius*math.pi/180.0) for v in inlist(value)])
def nod(self, value):
return outlist([(v*1852.0/3600.0)/(self.radius*math.pi/180.0) for v in inlist(value)])
"""
"""
# DEGREES only
class CIRCLE:
def arclen(radius, degrees=1):
return outlist([degrees*r*math.pi/180.0 for r in inlist(radius)])
def hordlen(radius, degrees=1):
return outlist([math.sin((degrees*math.pi/180.0)/2.0)*r*2 for r in inlist(radius)])
def length(radius):
return outlist([(r*2*math.pi) for r in inlist(radius)])
def timeround(radius, velocity):
return outlist([(r*2*math.pi)/velocity for r in inlist(radius)])
# degrees per second
def dps(radius, velocity):
return outlist([1.0/(CIRCLE.arclen(r)/velocity) for r in inlist(radius)])
#print(CIRCLE.arclen(GRID, 180))
#print(CIRCLE.hordlen(GRID, 180))
vel = MPS.nod(10.2)
print ("Velocity = %f m/s %f km/h %f nods" % (vel, KMH.mps(vel), NOD.mps(vel)))
print ("----")
for d in GRID:
dps = DPS(d).mps(vel)
print ("% 5d meters: % 2.3f deg/s %3.3f deg/min around % 5.1f min " % (d, dps, dps*60, (360.0/dps)/60) )