This repository was archived by the owner on Aug 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathassists_test.go
More file actions
47 lines (43 loc) · 1.38 KB
/
Copy pathassists_test.go
File metadata and controls
47 lines (43 loc) · 1.38 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
package smd
import (
"testing"
"github.com/gonum/floats"
)
func TestBPlane(t *testing.T) {
// The following values are correct according to Dr. Davis.
rSOI := []float64{546507.344255845, -527978.380486028, 531109.066836708}
vSOI := []float64{-4.9220589268733, 5.36316523097915, -5.22166308425181}
orbit := NewOrbitFromRV(rSOI, vSOI, Earth)
// Compute nominal values
initBPlane := NewBPlane(*orbit)
expBR := 10606.210428
expBT := 45892.323790
if !floats.EqualWithinAbs(initBPlane.BR, expBR, 1e-6) {
t.Fatalf("BR got: %f\nexp:%f", initBPlane.BR, expBR)
}
if !floats.EqualWithinAbs(initBPlane.BT, expBT, 1e-6) {
t.Fatalf("BT got: %f\nexp:%f", initBPlane.BT, expBT)
}
// Let's test the B-Plane correction too.
initBPlane.SetBRGoal(5022.26511510685, 1e-6)
initBPlane.SetBTGoal(13135.7982982557, 1e-6)
finalV, err := initBPlane.AchieveGoals(2)
if err != nil {
t.Fatalf("%s\n", err)
}
expV := []float64{-5.222055735935133, 5.221567577651425, -5.22166308425181}
for i := 0; i < 3; i++ {
if !floats.EqualWithinAbs(expV[i], finalV[i], 1e-8) {
t.Fatal("invalid TCM computed")
}
}
}
// Simply tests that GARPeriapsis and GATurnAngle are complementary
func TestGARpAngle(t *testing.T) {
vInf := 8.970655
ψ := GATurnAngle(vInf, 300, Earth)
rP := GARPeriapsis(vInf, ψ, Earth)
if !floats.EqualWithinAbs(rP, 300, 1e-11) {
t.Fatalf("got %.12f km when expecting 300 km.", rP)
}
}