important bug fix:infinite recursion occurs on constellation calculation

master
兔子 3 years ago
parent a23770a0b6
commit a225f49209

@ -141,17 +141,14 @@ func init() {
CstLists["VIR"] = []cst{cst{174.35052458333, -0.6916979}, cst{174.36568791667, 10.3082914}, cst{179.60373458333, 10.3040485}, cst{179.60453541667, 13.3040485}, cst{194.0620275, 13.3225126}, cst{194.05906625, 14.3225088}, cst{204.02893041667, 14.3604937}, cst{204.06384875, 7.3605771}, cst{227.78148625, 7.5253930}, cst{227.85301208333, -0.4742887}, cst{221.6030925, -0.5269387}, cst{221.66710791667, -8.5266848}, cst{215.40850625, -8.5731344}, cst{215.51309125, -22.5727749}, cst{194.16687, -22.6773415}, cst{194.1330525, -11.6773882}, cst{179.09676, -11.6957970}, cst{179.09860625, -6.6957974}, cst{174.34229875, -6.6916924}} CstLists["VIR"] = []cst{cst{174.35052458333, -0.6916979}, cst{174.36568791667, 10.3082914}, cst{179.60373458333, 10.3040485}, cst{179.60453541667, 13.3040485}, cst{194.0620275, 13.3225126}, cst{194.05906625, 14.3225088}, cst{204.02893041667, 14.3604937}, cst{204.06384875, 7.3605771}, cst{227.78148625, 7.5253930}, cst{227.85301208333, -0.4742887}, cst{221.6030925, -0.5269387}, cst{221.66710791667, -8.5266848}, cst{215.40850625, -8.5731344}, cst{215.51309125, -22.5727749}, cst{194.16687, -22.6773415}, cst{194.1330525, -11.6773882}, cst{179.09676, -11.6957970}, cst{179.09860625, -6.6957974}, cst{174.34229875, -6.6916924}}
CstLists["VOL"] = []cst{cst{98.93724875, -64.1070251}, cst{98.454422916667, -70.1041336}, cst{97.770709583333, -75.1000366}, cst{114.21470375, -75.2899170}, cst{135.24368708333, -75.4954681}, cst{136.09472708333, -64.4990387}, cst{102.70331375, -64.1518784}} CstLists["VOL"] = []cst{cst{98.93724875, -64.1070251}, cst{98.454422916667, -70.1041336}, cst{97.770709583333, -75.1000366}, cst{114.21470375, -75.2899170}, cst{135.24368708333, -75.4954681}, cst{136.09472708333, -64.4990387}, cst{102.70331375, -64.1518784}}
CstLists["VUL"] = []cst{cst{284.33913291667, 21.2478352}, cst{284.27716208333, 25.6641407}, cst{290.16131375, 25.7325745}, cst{290.13264625, 27.7324085}, cst{296.27220125, 27.8011742}, cst{296.25094375, 29.3010578}, cst{315.07258375, 29.4871387}, cst{315.08391458333, 28.4871883}, cst{322.62016375, 28.5480537}, cst{322.66201958333, 24.0482101}, cst{320.15170041667, 24.0289364}, cst{320.18840875, 20.0290813}, cst{317.17878291667, 20.0046406}, cst{309.907665, 19.9399967}, cst{309.89693708333, 20.9399471}, cst{305.13404875, 20.8936996}, cst{305.12540875, 21.6436558}, cst{298.860255, 21.5787334}, cst{298.88568875, 19.4955387}, cst{290.12128791667, 19.3982983}, cst{290.09631125, 21.3148155}} CstLists["VUL"] = []cst{cst{284.33913291667, 21.2478352}, cst{284.27716208333, 25.6641407}, cst{290.16131375, 25.7325745}, cst{290.13264625, 27.7324085}, cst{296.27220125, 27.8011742}, cst{296.25094375, 29.3010578}, cst{315.07258375, 29.4871387}, cst{315.08391458333, 28.4871883}, cst{322.62016375, 28.5480537}, cst{322.66201958333, 24.0482101}, cst{320.15170041667, 24.0289364}, cst{320.18840875, 20.0290813}, cst{317.17878291667, 20.0046406}, cst{309.907665, 19.9399967}, cst{309.89693708333, 20.9399471}, cst{305.13404875, 20.8936996}, cst{305.12540875, 21.6436558}, cst{298.860255, 21.5787334}, cst{298.88568875, 19.4955387}, cst{290.12128791667, 19.3982983}, cst{290.09631125, 21.3148155}}
change := []string{"PSC", "TUC", "PHE", "SCL", "CET", "PEG", "AND", "CAS", "CEP"} change := []string{"PSC", "TUC", "PHE", "SCL", "CET", "PEG", "AND", "CAS", "CEP"}
for _, v := range change { for _, v := range change {
for k, v2 := range CstLists[v] { for k, v2 := range CstLists[v] {
if v2.RA < 270 { if v2.RA < 270 {
CstLists[v][k].RA = v2.RA + 360 CstLists[v][k].RA = v2.RA + 360
} }
} }
} }
} }
//选定 RA=277.5 DEC=-40 //选定 RA=277.5 DEC=-40
@ -192,11 +189,11 @@ func isCross(a, b, c, d cst) bool {
func IsXZ(ra, dec, jde float64) string { func IsXZ(ra, dec, jde float64) string {
var nra, ndec float64 var nra, ndec float64
nra = ra nra = ra
if ra > 360 { if ra >= 360 {
nra = ra - 360 nra -= 360
} }
nra, ndec = ZuoBiaoSuiCha(nra, dec, jde, 2451545.0) nra, ndec = ZuoBiaoSuiCha(nra, dec, jde, 2451545.0)
if ra > 360 && nra < 300 { if ra >= 360 && nra < 270 {
nra += 360 nra += 360
} }
for k, v := range CstLists { for k, v := range CstLists {
@ -221,7 +218,7 @@ func IsXZ(ra, dec, jde float64) string {
return k return k
} }
} }
if nra <= 360 { if nra <= 270 {
ra = ra + 360 ra = ra + 360
return IsXZ(ra, dec, jde) return IsXZ(ra, dec, jde)
} }

@ -1,9 +1,16 @@
package basic package basic
import ( import (
"fmt"
"testing" "testing"
) )
func Test_Isxz(t *testing.T) { func Test_Isxz(t *testing.T) {
now := GetNowJDE()
for i := 0.00; i <= 360.00; i+=0.5 {
for j := -90.00; j <= 90.00; j+=0.5 {
fmt.Println(i, j)
fmt.Println(WhichCst(float64(i), float64(j), now))
}
}
} }

@ -1,9 +1,7 @@
package tools package tools
import ( import (
"fmt"
"math" "math"
"strconv"
) )
func Sin(x float64) float64 { func Sin(x float64) float64 {
@ -31,9 +29,8 @@ func ArcTan(x float64) float64 {
} }
func FloatRound(f float64, n int) float64 { func FloatRound(f float64, n int) float64 {
format := "%." + strconv.Itoa(n) + "f" p := math.Pow10(n)
res, _ := strconv.ParseFloat(fmt.Sprintf(format, f), 64) return math.Floor(f*p+0.5) / p
return res
} }
func Limit360(x float64) float64 { func Limit360(x float64) float64 {

Loading…
Cancel
Save