GithubHelp home page GithubHelp logo

djben / graviton Goto Github PK

View Code? Open in Web Editor NEW
58.0 8.0 11.0 162.43 MB

Real-time night sky rendering and planetarium in Swift 4 with native SceneKit and Metal.

License: GNU General Public License v3.0

Swift 94.72% Objective-C 2.63% GLSL 0.22% Ruby 0.55% Python 1.84% Shell 0.02%
astronomy orbital-mechanics ios-swift realmswift constellation swift swift4 stellarium

graviton's Introduction

Header image

Graviton 🌌

Language Build Status codebeat badge License: GPL v3

  • Real-time night sky and solar system rendering.
  • Astronomy and celestial mechanics toolkit.
  • Native Apple technologies with Swift 4 and SceneKit.

App

  • Real-time night sky rendering. Fully customizable. Totally hackable.
    • Reading from GPS or inputing custom position to see a night sky in your location.
    • Time warp - see what night sky is like at any time.
  • Real-time high accuracy solar system illustration. In scale.
  • Detailed celestial body information. Rise, transit and set information panel for ☀️, 🌛 and naked-eye planets.

Screenshots

Stellarium Planets Metadata Celestial body
main planets rts celestial-body

Getting Started

Xcode 14, iOS 16 is required. This app is built with Swift Package Manager, open Graviton.xcodeproj.

Features

The work is primarily done in the year of 2017 and 2018. It is frozen as of Jul 2023.

Stellarium

  1. View the simulated night sky at your local position and local time. Find the constellations and solar system plants.
  2. Time warp to any time in the past and future to view the predicted night sky.
  3. Browse the celestial object catalog, search the desired celestial objects and inspect their physical properties.

Planets

  1. View the real-time solar system.
  2. Goes forward in time to see the motion of heaven.

Information

  1. Astronomic properties including Julian date, LST offset and more.
  2. Rise, transit and set time of the sun, the moon and all planets.

Two websites are planned to be built. One includes all documentation, the other is a shiny front page for maximum appeal.

This project is a monorepo that also contains multiple useful frameworks. See below section.

Goals

Outdated

This is an amateurish project by an amateur astronomer. As a lover of science and space exploration, there are a few long-term goals:

  • A full-fledged open source stellarium software
  • An educational astronomy app with science in mind
  • (?) A space flight simulator that utilizes patched conics approximation.

Copyright

This project is licensed under GPLv3. If you have issues with any assets or resources in Graviton, please don't hesitate to reach out DJBen.

Frameworks

Orbits

High accuracy ephemeris query and orbital mechanics calculation framework.

  • Calculate Keplarian orbital mechanics with support of all conics.
  • Query and process high accuracy ephemeris from NASA JPL's Horizon interface and automatically cache results using Realm and SQLite.
  • Excellent offline mode. Stock ephemeris from 1500 AD to 3000 AD of major celestial bodies.
  • Support querying rise, transit and set timestamps for major celestial bodies.

Conics model predicts the orbits of the major planets in our solar system pretty accurately. To account for 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.

Header image

StarryNight

Language License: GPL v3

Overview

StarryNight is all you need for curiosity towards stars and constellations.

  • Database of 15000+ stars within 7th magnitude.
    • Star Catalogs including HR, HD, HIP, Gould and Bayer-Flamsteed designations.
    • Celestial coordinate and proper motion.
    • Visual and absolute magnitude, luminance, spectral type, binary star info, and other physical properties.
  • Extended Constellation support.
    • Position query and inverse position query.
    • Constellation line and constellation border.
    • Abbreviation, genitive and etymology.

Usage

Stars

  1. All stars brighter than...
Star.magitudeLessThan(7)
  1. Star with specific designation.
Star.hr(9077)
Star.hd(224750)
Star.hip(25)
  1. Star closest to specific celestial coordinate.

This is very useful to locate the closest star to user input.

let coord = Vector3.init(equatorialCoordinate: EquatorialCoordinate.init(rightAscension: radians(hours: 5, minutes: 20), declination: radians(degrees: 10), distance: 1)).normalized()
Star.closest(to: coord, maximumMagnitude: 2.5)
// Bellatrix

Constellations

  1. Constellation with name or IAU symbol.
Constellation.iau("Tau")
Constellation.named("Orion")
  1. Constellation that contains specific celestial coordinate.

This is very useful to locate the constellation that contains the region of user input.

It is implemented as a category on EquatorialCoordinate. See SpaceTime repo for implementation and usage of coordinate classes.

let coord = EquatorialCoordinate.init(rightAscension: 1.547, declination: 0.129, distance: 1)
coord.constellation
// Orion
  1. Neighboring constellations and centers.
// Get a set of neighboring constellations
Constellation.iau("Ori").neighbors
// Get the coordinate of center(s) of current constellation
Constellation.iau("Ori").displayCenters

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.

Remarks

Data extracted from 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.

Header

SpaceTime

Language License: GPL v3

Overview

Demo

Screenshot

Usage

Equatorial to horizontal coordinate:

// Supply observer location and timestamp
let locTime = ObserverLocationTime(location: location, timestamp: JulianDay.now)
let vegaCoord = EquatorialCoordinate(rightAscension: radians(hours: 18, minutes: 36, seconds: 56.33635), declination: radians(degrees: 38, minutes: 47, seconds: 1.2802), distance: 1)
// Azimuth and altitude of Vega
let vegaAziAlt = HorizontalCoordinate.init(equatorialCoordinate: vegaCoord, observerInfo: locTime)

Ecliptic coordinate of Pollux at standard equinox of J2000.0.

let ra = DegreeAngle(116.328942)
let dec = DegreeAngle(28.026183)
let eclipticCoord = EclipticCoordinate(longitude: ra, latitude: dec, distance: 1, julianDay: .J2000)
eclipticCoord.longitude.wrappedValue // 113.21563
eclipticCoord.latitude.wrappedValue // 6.68417

Greenwich Mean Sidereal Time:

SiderealTime.init(julianDay: JulianDay.now)

Local Apparent Sidereal Time:

// Get location from GPS or hard code
let locTime = ObserverLocationTime(location: location, timestamp: JulianDay.now)
let localSidTime = SiderealTime.init(observerLocationTime: locTime)

More use cases can be found in the source and test cases.

Startracker

A startracker is included to obtain precise alignment to the stars when viewing at night. To compile the app/run tests, you will first need to download the image files from: https://drive.google.com/drive/folders/1aB7_yC7U4iHJOtRk4fT2sOnFLDsacUH5?usp=sharing. The directories in the drive correspond to directories in this repo. Place the files into the corresponding repo directory.

To further develop/test the startracker, there are two methods:

  1. Simulation code from Python (see py/README.md)
  2. Real images where stars have been externally identified. These images should ideally come from the long-exposure photo capture functionality in Graviton's startracker, as those images would represent what the app could realistically capture. The app saves all photos to the photo library to facilitate this type of debugging.

Both types of images can be converted into unit tests on the Swift side.

Coordinare Systems

The following are differrent coordinate systems used throughout the codebase. A transformation between two coordinate systems is denoted T_{space_to}_{space_from}.

Ceq (Catalog Equatorial)

  • The catalog is full of vectors in the Equatorial coordinate system

Cc (Catalog Camera)

  • Cameras should have +x being horizontal to the right, +y being vertical and downwards, and +z point out of the camera to the scene. The Cc system refers to a hypothetical camera placed at the same origin/orientation as the Ceq system, but using camera conventions.

Meq (Mobile Equatorial)

  • The mobile view in Equatorial coordinate system

Mc (Mobile Camera)

  • The mobile camera system

graviton's People

Contributors

djben avatar e-001 avatar jmathur25 avatar vanshady avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graviton's Issues

Correct Moon orientation in observer view

Being a systematic issue, here's the plan of how to utilize data from Horizons

  1. Use npRa and npDec to align North Pole to the correct orientation.
  2. Rotate around the polar axis above to orient longitude to the sub-observer longitude.

Failed to build dependency MathUtil

$carthage update --platform iOS --no-use-binaries

*** Building scheme "MathUtil" in MathUtil.xcodeproj
Build Failed
	Task failed with exit code 70:
	/usr/bin/xcrun xcodebuild -project /Users/yang/Project/Graviton/Carthage/Checkouts/MathUtil/MathUtil.xcodeproj -scheme MathUtil -configuration Release -derivedDataPath /Users/yang/Library/Caches/org.carthage.CarthageKit/DerivedData/MathUtil/0.1.2 -sdk iphonesimulator -destination platform=iOS\ Simulator,id=422346F8-8318-4109-B440-C3B629E5DBA7 -destination-timeout 3 ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES build (launched in /Users/yang/Project/Graviton/Carthage/Checkouts/MathUtil)

The log:

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
		{ platform:iOS Simulator, id:422346F8-8318-4109-B440-C3B629E5DBA7 }

	Ineligible destinations for the "MathUtil" scheme:
		{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Generic iOS Device }
		{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Generic iOS Simulator Device }

Add Zenith / Nadir indicator

When pitching the camera near zenith or nadir, there should be an indicator to inform user that further pitching is impossible.

Time Warp

  • Experimental feature flag
  • Make sure that ephemeris switching keeps local
  • Warping backwards does not work. Solve this.
  • Freaking random malloc_error_break: Graviton(3977,0x16e087000) malloc: *** error for object 0x174871400: Invalid pointer dequeued from free list
  • Bug: time warp shakes the horizon
  • Bug: time warp disables ephemeris update every 10 secs

Architecture change of OrbitalMotion <-> CelestialBody relationship

Current references:

                                                      DB
                                                      |
CelestialBody <--(motion)-- Motion† <--(centerBody)-- CelestialBody <--(motion)-- Motion*

The first and third CelestialBody are not the same instance because the latter is initialized on the fly from the database without any motion info.

Proposed changes:

MotionManager              DB
|                          |
Motion <--(affectedBody)-- CelestialBody
     + <--(centerBody)-- CelestialBody

where CelestialBody are independent from Motion.

Increase performance of observer view

Some ideas:

  • Adaptive star loading: load big magnitude stars when FoV is wide and load subsequent smaller ones when FoV is small
  • Reduce constraints calculation cost
  • Stop calculating useless constraints

Settings Dependency

For example, invalidate some settings when a boolean setting item is enabled.

Website

  • index page
  • documentation using mkdocs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.