{"id":22435458,"url":"https://github.com/djben/graviton","last_synced_at":"2025-06-12T12:07:52.823Z","repository":{"id":52957730,"uuid":"68245199","full_name":"DJBen/Graviton","owner":"DJBen","description":"Real-time night sky rendering and planetarium in Swift 4 with native SceneKit and Metal.","archived":false,"fork":false,"pushed_at":"2023-11-17T16:21:30.000Z","size":166327,"stargazers_count":64,"open_issues_count":15,"forks_count":14,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-08T00:13:33.311Z","etag":null,"topics":["astronomy","constellation","ios-swift","orbital-mechanics","realmswift","stellarium","swift","swift4"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DJBen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-09-14T21:34:07.000Z","updated_at":"2025-04-05T13:57:56.000Z","dependencies_parsed_at":"2023-11-17T06:00:10.105Z","dependency_job_id":null,"html_url":"https://github.com/DJBen/Graviton","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/DJBen/Graviton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DJBen%2FGraviton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DJBen%2FGraviton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DJBen%2FGraviton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DJBen%2FGraviton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DJBen","download_url":"https://codeload.github.com/DJBen/Graviton/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DJBen%2FGraviton/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259462520,"owners_count":22861509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astronomy","constellation","ios-swift","orbital-mechanics","realmswift","stellarium","swift","swift4"],"created_at":"2024-12-05T23:13:43.036Z","updated_at":"2025-06-12T12:07:52.766Z","avatar_url":"https://github.com/DJBen.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Header image](https://github.com/DJBen/Graviton/raw/master/External%20Assets/G-Purple.png)\n\n# Graviton :milky_way:\n\n[![Language](https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat)](https://swift.org)\n[![Build Status](https://travis-ci.com/DJBen/Graviton.svg?token=1KVrf6xTWoPqLKJBPuJ1\u0026branch=master)](https://travis-ci.com/DJBen/Graviton)\n[![codebeat badge](https://codebeat.co/badges/de61d36c-440a-4cc7-85cf-97379e08ef15)](https://codebeat.co/a/sihao-lu/projects/github-com-djben-graviton-master?maxAge=3600)\n[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)\n\n- _Real-time night sky and solar system rendering._\n- _Astronomy and celestial mechanics toolkit._\n- _Native Apple technologies with Swift 4 and SceneKit._\n----\n## App\n- [x] Real-time night sky rendering. Fully customizable. Totally hackable.\n  - [x] Reading from GPS or inputing custom position to see a night sky in your location.\n  - [x] Time warp - see what night sky is like at any time.\n- [x] Real-time high accuracy solar system illustration. In scale.\n- [x] Detailed celestial body information. Rise, transit and set information panel for :sunny:, :first_quarter_moon_with_face: and naked-eye planets.\n\n## Screenshots\n\n| Stellarium | Planets | Metadata | Celestial body |\n| --- | --- | --- | --- |\n| ![main](https://github.com/DJBen/Graviton/raw/master/External%20Assets/screenshot-main.png) | ![planets](https://github.com/DJBen/Graviton/raw/master/External%20Assets/screenshot-planet.png) | ![rts](https://github.com/DJBen/Graviton/raw/master/External%20Assets/screenshot-rts.png) | ![celestial-body](https://github.com/DJBen/Graviton/raw/master/External%20Assets/screenshot-celestial-body.png) |\n\n## Getting Started\n\nXcode 14, iOS 16 is required. This app is built with Swift Package Manager, open `Graviton.xcodeproj`.\n\n## Features\n*The work is primarily done in the year of 2017 and 2018. It is frozen as of Jul 2023.*\n\n### Stellarium\n1. View the simulated night sky at your local position and local time. Find the constellations and solar system plants.\n2. Time warp to any time in the past and future to view the predicted night sky.\n3. Browse the celestial object catalog, search the desired celestial objects and inspect their physical properties.\n\n### Planets\n1. View the real-time solar system.\n2. Goes forward in time to see the motion of heaven.\n\n### Information\n1. Astronomic properties including Julian date, LST offset and more.\n2. Rise, transit and set time of the sun, the moon and all planets.\n\nTwo websites are planned to be built. One includes all documentation, the other is a shiny front page for maximum appeal.\n\nThis project is a monorepo that also contains multiple useful frameworks. See below section.\n\n## Goals\n\n\u003e **Outdated**\n\nThis is an amateurish project by an amateur astronomer. As a lover of science and space exploration, there are a few long-term goals:\n\n- A full-fledged open source stellarium software\n- An educational astronomy app with science in mind\n- (?) A space flight simulator that utilizes [patched conics approximation](https://en.wikipedia.org/wiki/Patched_conic_approximation).\n\n## Copyright\nThis project is licensed under GPLv3.\nIf you have issues with any assets or resources in Graviton, please don't hesitate to reach out [DJBen](mailto:lsh32768@gmail.com).\n\n# Frameworks\n## Orbits\n_High accuracy ephemeris query and orbital mechanics calculation framework._\n- [x] Calculate [Keplarian](https://en.wikipedia.org/wiki/Kepler_orbit) orbital mechanics with support of all [conics](https://en.wikipedia.org/wiki/Conic_section).\n- [x] Query and process high accuracy ephemeris from NASA JPL's [Horizon](http://ssd.jpl.nasa.gov/?horizons) interface and automatically cache results using [Realm](https://realm.io) and SQLite.\n- [x] Excellent offline mode. Stock ephemeris from 1500 AD to 3000 AD of major celestial bodies.\n- [x] Support querying rise, transit and set timestamps for major celestial bodies.\n\n\u003e Conics model predicts the orbits of the major planets in our solar system pretty accurately. To account for [apsidal precession](https://en.wikipedia.org/wiki/Apsidal_precession) and other orbital perturbations of celestial bodies like Mercury and Earth's moon, Orbits fetches many data points from JPL and cherry-pick the orbital configuration closest to the reference time.\n\n### ![Header image](https://github.com/DJBen/StarryNight/raw/master/External%20Assets/S-Green.png)\n\n## StarryNight\n[![Language](https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat)](https://swift.org)\n[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)\n\n### Overview\n_StarryNight is all you need for curiosity towards stars and constellations._\n\n- Database of 15000+ stars within 7th magnitude.\n  - [Star Catalogs](https://en.wikipedia.org/wiki/Star_catalogue) including HR, HD, HIP, [Gould](https://en.wikipedia.org/wiki/Gould_designation) and [Bayer](https://en.wikipedia.org/wiki/Bayer_designation)-[Flamsteed](https://en.wikipedia.org/wiki/Flamsteed_designation) designations.\n  - Celestial coordinate and proper motion.\n  - Visual and absolute magnitude, luminance, spectral type, binary star info, and other physical properties.\n- Extended Constellation support.\n  - Position query and inverse position query.\n  - Constellation line and constellation border.\n  - Abbreviation, genitive and etymology.\n\n\n### Usage\n\n#### Stars\n\n1. All stars brighter than...\n\n```swift\nStar.magitudeLessThan(7)\n```\n2. Star with specific designation.\n\n```swift\nStar.hr(9077)\nStar.hd(224750)\nStar.hip(25)\n```\n3. Star closest to specific celestial coordinate.\n\nThis is very useful to locate the closest star to user input.\n\n```swift\nlet coord = Vector3.init(equatorialCoordinate: EquatorialCoordinate.init(rightAscension: radians(hours: 5, minutes: 20), declination: radians(degrees: 10), distance: 1)).normalized()\nStar.closest(to: coord, maximumMagnitude: 2.5)\n// Bellatrix\n```\n\n#### Constellations\n\n1. Constellation with name or [IAU symbol](https://www.iau.org/public/themes/constellations/).\n```swift\nConstellation.iau(\"Tau\")\nConstellation.named(\"Orion\")\n```\n2. Constellation that contains specific celestial coordinate.\n\nThis is very useful to locate the constellation that contains the region of user input.\n\n  It is implemented as a category on `EquatorialCoordinate`. See [SpaceTime](https://github.com/DJBen/SpaceTime) repo for implementation and usage of coordinate classes.\n\n```swift\nlet coord = EquatorialCoordinate.init(rightAscension: 1.547, declination: 0.129, distance: 1)\ncoord.constellation\n// Orion\n```\n\n3. Neighboring constellations and centers.\n\n```swift\n// Get a set of neighboring constellations\nConstellation.iau(\"Ori\").neighbors\n// Get the coordinate of center(s) of current constellation\nConstellation.iau(\"Ori\").displayCenters\n```\n\n  *Note*: `displayCenters` returns an array of one element for all constellations except Serpens, which will include two elements - one center for Serpens Caput and the other for Serpens Cauda.\n\n### Remarks\nData extracted from [HYG database](https://github.com/astronexus/HYG-Database) and processed into SQLite. The star catalog has been trimmed to 7th magnitude to reduce file size. Feel free to download the full catalog and import into SQLite whenever you see fit.\n\n![Header](https://github.com/DJBen/SpaceTime/raw/master/External%20Assets/T-Blue.png)\n\n# SpaceTime\n\n[![Language](https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat)](https://swift.org)\n[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n\n## Overview\n\n- Conversion among [equatorial coordinate](https://en.wikipedia.org/wiki/Equatorial_coordinate_system) (right ascension and declination), [horizontal coordinate](https://en.wikipedia.org/wiki/Horizontal_coordinate_system) (azimuth and altitude),\n[ecliptic coordinate](https://en.wikipedia.org/wiki/Ecliptic_coordinate_system) (longitude and latitude) and their corresponding Cartesian equivalents.\n- Calculate [Julian Day](https://en.wikipedia.org/wiki/Julian_day) and [Local sidereal time](https://en.wikipedia.org/wiki/Sidereal_time).\n- High precision calculation of the [obliquity of ecliptic](https://en.wikipedia.org/wiki/Ecliptic) good to 0″.04 / 1000 years over 10000 years.\n- Matrix / Quaternion transformation from celestial coordinate system to local tangent plane. Supports [North-East-Down](https://en.wikipedia.org/wiki/North_east_down) coordinate from [earth-centered, earth-fixed](https://en.wikipedia.org/wiki/ECEF) coordinate system for any given longitude, latitude and timestamp.\n\n## Demo\n![Screenshot](https://github.com/DJBen/SpaceTime/raw/master/External%20Assets/Screenshot.png)\n\n## Usage\nEquatorial to horizontal coordinate:\n```swift\n// Supply observer location and timestamp\nlet locTime = ObserverLocationTime(location: location, timestamp: JulianDay.now)\nlet vegaCoord = EquatorialCoordinate(rightAscension: radians(hours: 18, minutes: 36, seconds: 56.33635), declination: radians(degrees: 38, minutes: 47, seconds: 1.2802), distance: 1)\n// Azimuth and altitude of Vega\nlet vegaAziAlt = HorizontalCoordinate.init(equatorialCoordinate: vegaCoord, observerInfo: locTime)\n```\nEcliptic coordinate of Pollux at standard equinox of J2000.0.\n```swift\nlet ra = DegreeAngle(116.328942)\nlet dec = DegreeAngle(28.026183)\nlet eclipticCoord = EclipticCoordinate(longitude: ra, latitude: dec, distance: 1, julianDay: .J2000)\neclipticCoord.longitude.wrappedValue // 113.21563\neclipticCoord.latitude.wrappedValue // 6.68417\n```\nGreenwich Mean Sidereal Time:\n```swift\nSiderealTime.init(julianDay: JulianDay.now)\n```\nLocal Apparent Sidereal Time:\n```swift\n// Get location from GPS or hard code\nlet locTime = ObserverLocationTime(location: location, timestamp: JulianDay.now)\nlet localSidTime = SiderealTime.init(observerLocationTime: locTime)\n```\nMore use cases can be found in the source and test cases.\n\n# Startracker\nA startracker is included to obtain precise alignment to the stars when viewing at night.\nTo compile the app/run tests, you will first need to download the image files from:\nhttps://drive.google.com/drive/folders/1aB7_yC7U4iHJOtRk4fT2sOnFLDsacUH5?usp=sharing.\nThe directories in the drive correspond to directories in this repo. Place the files\ninto the corresponding repo directory.\n\nTo further develop/test the startracker, there are two methods:\n1. Simulation code from Python (see `py/README.md`)\n2. Real images where stars have been externally identified. These images should ideally come\nfrom the long-exposure photo capture functionality in Graviton's startracker, as those images\nwould represent what the app could realistically capture. The app saves all photos to the photo\nlibrary to facilitate this type of debugging.\n\nBoth types of images can be converted into unit tests on the Swift side.\n\n# Coordinare Systems\nThe following are differrent coordinate systems used throughout the codebase. A transformation\nbetween two coordinate systems is denoted `T_{space_to}_{space_from}`.\n\nCeq (Catalog Equatorial)\n- The catalog is full of vectors in the Equatorial coordinate system\n\nCc (Catalog Camera)\n- Cameras should have +x being horizontal to the right, +y being vertical\n and downwards, and +z point out of the camera to the scene. The `Cc`\n system refers to a hypothetical camera placed at the same origin/orientation\n as the `Ceq` system, but using camera conventions.\n\nMeq (Mobile Equatorial)\n- The mobile view in Equatorial coordinate system\n\nMc (Mobile Camera)\n- The mobile camera system\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjben%2Fgraviton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjben%2Fgraviton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjben%2Fgraviton/lists"}