Skip to content

Commit

Permalink
Removed irrelevant code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherRabotin committed Nov 11, 2016
1 parent 11b81ac commit d313462
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
5 changes: 0 additions & 5 deletions examples/angularMomentum/attitude.go
@@ -1,7 +1,6 @@
package dynamics

import (
"fmt"
"math"

"github.com/gonum/matrix/mat64"
Expand Down Expand Up @@ -97,10 +96,6 @@ func (s *MRP) B() *mat64.Dense {
return B
}

func (s *MRP) String() string {
return fmt.Sprintf("[%1.5f %1.5f %1.5f]", s.s1, s.s2, s.s3)
}

// Attitude defines an attitude with an orientation, an angular velocity and an inertial tensor.
// *ALMOST* implements rk4.Integrable.
type Attitude struct {
Expand Down
22 changes: 1 addition & 21 deletions examples/angularMomentum/geometry.go
@@ -1,10 +1,6 @@
package dynamics

import (
"math"

"github.com/gonum/matrix/mat64"
)
import "math"

// norm returns the norm of a given vector which is supposed to be 3x1.
func norm(v []float64) float64 {
Expand All @@ -16,13 +12,6 @@ func dot(a, b []float64) float64 {
return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]
}

// cross performs the inner product.
func cross(a, b []float64) []float64 {
return []float64{a[1]*b[2] - a[2]*b[1],
a[2]*b[0] - a[0]*b[2],
a[0]*b[1] - a[1]*b[0]} // Cross product R x V.
}

// Spherical2Cartesian returns the provided spherical coordinates vector in Cartesian.
func Spherical2Cartesian(a []float64) (b []float64) {
b = make([]float64, 3)
Expand Down Expand Up @@ -55,12 +44,3 @@ func Deg2rad(a float64) float64 {
func Rad2deg(a float64) float64 {
return a / (2 * math.Pi) * 360.0
}

// MxV33 multiplies a matrix with a vector. Note that there is no dimension check!
func MxV33(m *mat64.Dense, v []float64) (o []float64) {
o = make([]float64, 3)
o[0] = m.At(0, 0)*v[0] + m.At(0, 1)*v[1] + m.At(0, 2)*v[2]
o[1] = m.At(1, 0)*v[0] + m.At(1, 1)*v[1] + m.At(1, 2)*v[2]
o[2] = m.At(2, 0)*v[0] + m.At(2, 1)*v[1] + m.At(2, 2)*v[2]
return
}
12 changes: 12 additions & 0 deletions integrable_test.go
@@ -0,0 +1,12 @@
package ode

import "testing"

func assertPanic(t *testing.T, msg string, f func()) {
defer func() {
if r := recover(); r == nil {
t.Errorf("code did not panic with %s", msg)
}
}()
f()
}
10 changes: 10 additions & 0 deletions rk4_test.go
Expand Up @@ -76,3 +76,13 @@ func TestRK4Attitude(t *testing.T) {
t.Fatalf("angular momentum changed by %4.12f", diff)
}
}

func TestPanics(t *testing.T) {
assertPanic(t, "negative step", func() {
NewRK4(1, -1, nil)
})

assertPanic(t, "nil integrator", func() {
NewRK4(1, 1, nil)
})
}

0 comments on commit d313462

Please sign in to comment.