<commit_before>package smd

import (
	"errors"
	"fmt"
	"math"
	"time"

	"github.com/gonum/floats"
)

const (
	// Precise ε
	eccentricityε = 5e-5                         // 0.00005
	angleε        = (5e-3 / 360) * (2 * math.Pi) // 0.005 degrees
	distanceε     = 2e1                          // 20 km
	// Coarse ε (for interplanetary flight)
	eccentricityLgε = 1e-2                         // 0.01
	angleLgε        = (5e-1 / 360) * (2 * math.Pi) // 0.5 degrees
	distanceLgε     = 5e2                          // 500 km
	// velocity ε for circular orbit equality and Hohmann
	velocityε = 1e-4 // in km/s
)

// Orbit defines an orbit via its orbital elements.
type Orbit struct {
	rVec, vVec []float64       // Stars with a lowercase to make private
	Origin     CelestialObject // Orbit origin
	// Cache management
	cacheHash, ccha, cche, cchi, cchΩ, cchω, cchν, cchλ, cchtildeω, cchu float64
}

// Energyξ returns the specific mechanical energy ξ.
func (o Orbit) Energyξ() float64 {
	a, e, _, _, _, _, _, _, _ := o.Elements()
	ξ := -o.Origin.μ / (2 * a)
	if e > 1 {
		ξ *= -1
	}
	return ξ
}

// H returns the orbital angular momentum vector.
func (o Orbit) H() []float64 {
	return cross(o.RV())
}

// HNorm returns the norm of orbital angular momentum.
func (o Orbit) HNorm() float64 {
	return o.RNorm() * o.VNorm() * o.CosΦfpa()
}

// CosΦfpa returns the cosine of the flight path angle.
// WARNING: As per Vallado page 105, *do not* use math.Acos(o.CosΦfpa())
// to get the flight path angle as you'll have a quadran problem. Instead
// use math.Atan2(o.GetSinΦfpa(), o.CosΦfpa()).
func (o Orbit) CosΦfpa() float64 {
	_, e, _, _, _, ν, _, _, _ := o.Elements()
	if e < eccentricityε {
		return 1
	} else if floats.EqualWithinAbs(e, 1, eccentricityε) {
		return math.Cos(ν / 2)
	} else if e > 1 {
		cosh2 := math.Pow((e+math.Cos(ν))/(1+e*math.Cos(ν)), 2)<commit_msg>(m) Change computation of energy<commit_after>package smd

import (
	"errors"
	"fmt"
	"math"
	"time"

	"github.com/gonum/floats"
)

const (
	// Precise ε
	eccentricityε = 5e-5                         // 0.00005
	angleε        = (5e-3 / 360) * (2 * math.Pi) // 0.005 degrees
	distanceε     = 2e1                          // 20 km
	// Coarse ε (for interplanetary flight)
	eccentricityLgε = 1e-2                         // 0.01
	angleLgε        = (5e-1 / 360) * (2 * math.Pi) // 0.5 degrees
	distanceLgε     = 5e2                          // 500 km
	// velocity ε for circular orbit equality and Hohmann
	velocityε = 1e-4 // in km/s
)

// Orbit defines an orbit via its orbital elements.
type Orbit struct {
	rVec, vVec []float64       // Stars with a lowercase to make private
	Origin     CelestialObject // Orbit origin
	// Cache management
	cacheHash, ccha, cche, cchi, cchΩ, cchω, cchν, cchλ, cchtildeω, cchu float64
}

// Energyξ returns the specific mechanical energy ξ.
func (o Orbit) Energyξ() float64 {
	return math.Pow(o.VNorm(), 2)/2 - o.Origin.μ/o.RNorm()
}

// H returns the orbital angular momentum vector.
func (o Orbit) H() []float64 {
	return cross(o.RV())
}

// HNorm returns the norm of orbital angular momentum.
func (o Orbit) HNorm() float64 {
	return o.RNorm() * o.VNorm() * o.CosΦfpa()
}

// CosΦfpa returns the cosine of the flight path angle.
// WARNING: As per Vallado page 105, *do not* use math.Acos(o.CosΦfpa())
// to get the flight path angle as you'll have a quadran problem. Instead
// use math.Atan2(o.GetSinΦfpa(), o.CosΦfpa()).
func (o Orbit) CosΦfpa() float64 {
	_, e, _, _, _, ν, _, _, _ := o.Elements()
	if e < eccentricityε {
		return 1
	} else if floats.EqualWithinAbs(e, 1, eccentricityε) {
		return math.Cos(ν / 2)
	} else if e > 1 {
		cosh2 := math.Pow((e+math.Cos(ν))/(1+e*math.Cos(ν)), 2)
{'fraction_non_alphanumeric': 0.13620362848632547, 'fraction_numerical': 0.036555645816409424, 'mean_word_length': 2.3735159817351597, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1802818', 'n_tokens_mistral': 1510, 'n_tokens_neox': 1376, 'n_words': 421}