Visualisation of star catalogues and celestial coordinates
You are trying to project points on a sphere onto a plane -- which is what map projections do. So yes, there are lots of resources for doing just that. If you can't find any, comment and I'll dig some out for you.
For the celestial sphere you are looking out towards the 'surface' of the sphere from inside, rather than, when you look at a map, from a notional point above the surface of the Earth looking down. But the maths is the same. And for the celestial sphere if you are just making nice pictures, you can stick to spherical maths, not all the ugly stuff that has to cope with an oblate spheroid with bumps like the Earth.
Swift - how can i correct sky map according to current time and location?
You just need to rotate your map with time+longitude
around Earth's rotation axis and with latitude
around axis longitude=90 degrees
while earth is placed in the center of your sphere. For stars the offset does not matter so you can ignore Sun-Earth distance and also Earth's radius as well.
The time rotation must be day+year
rotations together. On top of that you have to apply precession and nutation if you want to have higher precision.
Of coarse the stars are moving too so if you need really high precision and or high time interval to cover (hundreds or thousands of years) then this approach is not good and you should use stellar catalog with the motions implemented.
For more info see related:
- How to draw sky chart
- Plotting a star chart efficiently
If you want to use catalog and real colors then you will also need
- Star B-V color index to apparent RGB color
- simplified atmospheric scattering GLSL shader
And finally here some hints for such applications:
- Is it possible to make realistic n-body solar system simulation in matter of size and mass?
Add shape to sphere surface in SceneKit
If you want to map 2D content into the surface of a 3D SceneKit object, and have the 2D content be dynamic/interactive, one of the easiest solutions is to use SpriteKit for the 2D content. You can set your sphere's diffuse contents to an SKScene
, and create/position/decorate SpriteKit nodes in that scene to arrange them on the face of the sphere.
If you want to have this content respond to tap events... Using hitTest
in your SceneKit view gets you a SCNHitTestResult
, and from that you can get texture coordinates for the hit point on the sphere. From texture coordinates you can convert to SKScene
coordinates and spawn nodes, run actions, or whatever.
For further details, your best bet is probably Apple's SceneKitReel sample code project. This is the demo that introduced SceneKit for iOS at WWDC14. There's a "slide" in that demo where paint globs fly from the camera at a spinning torus and leave paint splashes where they hit it — the torus has a SpriteKit scene as its material, and the trick for leaving splashes on collisions is basically the same hit test -> texture coordinate -> SpriteKit coordinate approach outlined above.
Related Topics
How to Use an Nsattributedstring with a Scrollview in Swiftui
How to Loop Through View Outlets in a Uiviewcontroller with Swift
Aws Cognito Swift Credentials Provider "Logins Is Deprecated: Use Awsidentityprovidermanager"
Select() from Linq in Swift 3.0
Swiftui - Passing Data from Swiftuiview to Scenekit
Urlsession.Shared.Datataskpublisher Not Working on iOS 13.3
How to Transpose an Array More Swiftly
Cllocationcoordinate2D Can't Be Instantiated
Swift 2 to 3 Migration for Prepareforsegue
May I Create an Instance of a Structure Using a Simple Int
Using Variables Outside of Completion Block
In Swift 3, What Is a Way to Compare Two Closures
Convert a Swift Array of String to a to a C String Array Pointer