This repository has been archived by the owner on Feb 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_cop.py
52 lines (36 loc) · 1.33 KB
/
test_cop.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
48
49
50
51
52
import numpy as np
from pytest import approx
from cop import calculate_minimal_moment, find_another_point_on_cop_line
def test_cop():
# Test1 : simple values
Mref = np.array([0., 0., 1.])
F = np.array([0., 1., 1.])
Pref = np.array([1., 0., 0.])
Px = calculate_minimal_moment(F, Mref, Pref)
assert Px[0] == approx(1.49995, 1e-5)
assert Px[1] == 0
assert Px[2] == 0
Pcop, msg = find_another_point_on_cop_line(Px, F, "x")
assert msg == "Center of pressure line is parallel to the x plane"
Pcop, msg = find_another_point_on_cop_line(Px, F, "y")
print(Pcop)
assert msg == ""
assert Pcop[0] == approx(1.49995, 1e-5)
assert Pcop[1] == 0
assert Pcop[2] == 0
Pcop, msg = find_another_point_on_cop_line(Px, F, "z")
print(Pcop)
assert msg == ""
assert Pcop[0] == approx(1.49995, 1e-5)
assert Pcop[1] == 0
assert Pcop[2] == 0
# Test 2 : complex values
Mref = np.array([27406144, -56507355, 7762585])
F = np.array([229793, 395290, 1609545])
Pref = np.array([0., 0., 0.])
Px = calculate_minimal_moment(F, Mref, Pref)
Pcop, msg = find_another_point_on_cop_line(Px, F, "z")
assert msg == ""
assert Pcop[0] == approx(34.7967, 1e-5)
assert Pcop[1] == approx(17.2080, 1e-5)
assert Pcop[2] == 0