Esempio n. 1
0
func new_planet(id int, name string) *Body {

	planet := &Body{class: clPLANET, name: name}

	cs1 := C.CString("DUMMY")
	cs2 := C.CString("xxx")
	cs3 := C.CString(name)
	defer C.free(unsafe.Pointer(cs1))
	defer C.free(unsafe.Pointer(cs2))
	defer C.free(unsafe.Pointer(cs3))

	C.make_cat_entry(cs1, cs2, 0, 0, 0, 0, 0, 0, 0, &planet.cat_entry)
	if err := C.make_object(0, C.short(id), cs3, &planet.cat_entry, &planet.object); err != 0 {
		log.Fatalf("Error %d from make_object (%s)\n", int(err), name)
	}
	return planet
}
Esempio n. 2
0
File: star.go Progetto: pebbe/novas
/*
Create a star
    starname:       name of celestial object
    catalog:        catalog designator (e.g., HIP)
    starnumber:     integer identifier assigned to object
    ra:             ICRS right ascension (hours)
    dec:            ICRS declination (degrees)
    promora:        ICRS proper motion in right ascension (milliarcseconds/year)
    promodec:       ICRS proper motion in declination (milliarcseconds/year)
    parallax:       parallax (milliarcseconds)
    radialvelocity: radial velocity (km/s)
*/
func NewStar(starname, catalog string, starnumber int64, ra, dec, promora, promodec, parallax, radialvelocity float64) *Body {

	if len(starname) >= int(C.SIZE_OF_OBJ_NAME) {
		panic("Length of starname \"" + starname + "\" too long")
	}

	if len(catalog) >= int(C.SIZE_OF_CAT_NAME) {
		panic("Length of catalog \"" + catalog + "\" too long")
	}

	star := &Body{class: clSTAR, name: starname}

	cs1 := C.CString(starname)
	cs2 := C.CString(catalog)
	defer C.free(unsafe.Pointer(cs1))
	defer C.free(unsafe.Pointer(cs2))

	C.make_cat_entry(cs1, cs2, C.long(starnumber), C.double(ra), C.double(dec),
		C.double(promora), C.double(promodec), C.double(parallax), C.double(radialvelocity), &star.cat_entry)

	return star
}