Simple Orbiter

View previous topic View next topic Go down

Simple Orbiter

Post by LongtimeAirman on Thu Aug 27, 2015 12:46 am

Nevyn
” … I could find, orbital distance and velocity, precession, etc, and animated the planets rotating about the sun and the moons about their planets. Put textures on the sun and all of the planets and any moons that I could find. It did look pretty good”

You effort sounds terrific. Creating a working solar system in the first place is amazing. Is it fair to say that flipping the physics at that point made it even more difficult?

OK. Starting from simple.

There are n objects: 1,2,3,…,n. With attributes:
1) volume, from expanded mass (m = (volume)(density)): v1d1, v2d2, v3d3, …, vndn;
2) density, from expanded mass (m = (volume)(density)): d1, d2, d3, …, dn)
2) radius
3) positions (start with 2D?)
4) velocities (vectors)
5) axial spin (for later)

Call gravity (based on expansion theory - increase volumes, recalculate positions with respect to largest volume, renormalize radii, plot positions)
Call charge (recalculate velocities, recalc spins, reposition objects)

From “Maxwell’s Lines of Force Part 2”, E=C/G, the electric field is Charge divided by gravity. Charge is density. Or even easier, charge repulsion is an inverse cube vector added to the positions’ velocity vector.  

With charge and gravity inverse, this thing could vary between the two, scaling from the very small (charge dominates) to very large (gravity dominates). Given a set of common objects, wouldn’t this “program” set up a uniformly spaced lattice? Orbits may require a single very large mass.

You indicate complexity is the problem. Is this too simple?

LongtimeAirman
Admin

Posts : 612
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Simple Orbiter

Post by Nevyn on Thu Aug 27, 2015 5:16 am

That's a good outline. The devil is in the details.

Gravity is fairly straight forward since it is an action that only applies to the bodies themselves. There are complexities in normalizing the positions but nothing too difficult.

The charge field is the problem. Charge is something that actually exists. It takes up space and it has position and velocity, etc. Therefore it also has time, or more precisely, it takes time for it to do anything. So you can't just make simple calculations like you can with gravity.

It may not be too bad. I just haven't been able to see the right way forward. We can probably ignore intermingling charge fields and only use the distance between the target body and all others to determine their charge effects. I keep thinking I need a density field to handle the charge and its time differentials and that probably will be needed at some point but we can keep it a bit simpler for now.
avatar
Nevyn
Admin

Posts : 811
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Simple Orbiter

Post by Nevyn on Thu Aug 27, 2015 5:30 am

I've had a look over my old code and pulled out the solar system data and converted it into a JSON version. My original data was in XML and I have made the JSON fairly close to the XML structure only for simplicity of conversion. However, the structure does have meaning so it probably couldn't change too much anyway.

Here is the JSON version. I can't post it in one go so this is the outline and the following posts will contain planets. Each of the planets will go into the "Orbitals" object. If you take exactly what I post into the code sections and glue them back together then it should be valid JSON. Copy the following code to a file and then replace '...' with the code sections from each of the next few posts in the same order.

Code:

{
  "CentralBodies":
  {
    "Sun":
    {
      "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 7.25 ,"units": "degrees" }
      ,"rotation": { "period": 609.12, "units": "hours" }
      ,"Avatar":
      {
        "radius": 696000
        ,"density": 1408
        ,"mass": 1988500e24
        ,"texture": "res/images/astro/sunmap.jpg"
      }
    }
  }
  ,"Orbitals":
  {
    ...
  }
}

There is missing data on moons of various planets so if anyone wants to add them in, go for it and post the results back here. I'll create an app to visualise and animate it.
avatar
Nevyn
Admin

Posts : 811
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Simple Orbiter

Post by Nevyn on Thu Aug 27, 2015 5:32 am

Code:

    "Mercury":
    {
      "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 7 ,"units": "degrees" }
      ,"orbital": { "period": 88, "units": "days" }
      ,"location": { "x": 57.9e6, "y": 0, "z": 0 }
      ,"Body":
      {
        "name": "Mercury"
        ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.01 ,"units": "degrees" }
        ,"rotation": { "period": 1407.6, "units": "hours" }
        ,"Avatar":
        {
          "diameter": 4879
          ,"density": 5427
          ,"mass": 0.330e24
          ,"texture": "res/images/astro/mercurymap.jpg"
        }
      }
    }
    ,"Venus":
    {
      "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 3.4 ,"units": "degrees" }
      ,"orbital": { "period": -224.7, "units": "days" }
      ,"location": { "x": 108.2e6, "y": 0, "z": 0 }
      ,"Body":
      {
        "name": "Venus"
        ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 177.4 ,"units": "degrees" }
        ,"rotation": { "period": -5832.5, "units": "hours" }
        ,"Avatar":
        {
          "diameter": 12104
          ,"density": 5243
          ,"mass": 4.87e24
          ,"texture": "res/images/astro/venusmap.jpg"
        }
      }
    }
    ,"Earth":
    {
      "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0 ,"units": "degrees" }
      ,"orbital": { "period": 365.2, "units": "days" }
      ,"location": { "x": 149.6e6, "y": 0, "z": 0 }
      ,"Body":
      {
        "name": "Earth"
        ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 23.4 ,"units": "degrees" }
        ,"rotation": { "period": 23.9, "units": "hours" }
        ,"Avatar":
        {
          "diameter": 12756
          ,"density": 5514
          ,"mass": 5.97e24
          ,"texture": "res/images/astro/earthmap1k.jpg"
        }
        ,"Orbitals":
        {
          "Moon":
          {
            "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": -18.255 ,"units": "degrees" }
            ,"orbital": { "period": 27.3, "units": "days" }
            ,"location": { "x": 378000, "y": 0, "z": 0 }
            ,"Body":
            {
              "name": "Moon"
              ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 27.3 ,"units": "degrees" }
              ,"rotation": { "period": 655.7, "units": "hours" }
              ,"Avatar":
              {
                "diameter": 3475
                ,"density": 3340
                ,"mass": 0.073e24
                ,"texture": "res/images/astro/moonmap1k.jpg"
              }
            }
          }
        }
      }
    }
    ,"Mars":
    {
      "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 3.4 ,"units": "degrees" }
      ,"orbital": { "period": 687.0, "units": "days" }
      ,"location": { "x": 227.9e6, "y": 0, "z": 0 }
      ,"Body":
      {
        "name": "Mars"
        ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 25.2 ,"units": "degrees" }
        ,"rotation": { "period": 24.6, "units": "hours" }
        ,"Avatar":
        {
          "diameter": 6792
          ,"density": 3933
          ,"mass": 0.642e24
          ,"texture": "res/images/astro/mars_1k_color.jpg"
        }
      }
    }
    ,"Jupiter":
    {
      "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 1.3 ,"units": "degrees" }
      ,"orbital": { "period": 4331, "units": "days" }
      ,"location": { "x": 778.6e6, "y": 0, "z": 0 }
      ,"Body":
      {
        "name": "Jupiter"
        ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 3.1 ,"units": "degrees" }
        ,"rotation": { "period": 9.9, "units": "hours" }
        ,"Avatar":
        {
          "diameter": 142984
          ,"density": 1326
          ,"mass": 1898e24
          ,"texture": "res/images/astro/jupiter2_1k.jpg"
          ,"Ring":
          {
            "height": 1000
            ,"innerRadius": 100000
            ,"outerRadius": 224900
            ,"transparency": 0.2
            ,"textures":
            {
              "face": "res/images/astro/jupiter-ring.jpg"
              ,"outside": "res/images/astro/jupiter-ring-outer-edge.jpg"
              ,"inside": "res/images/astro/jupiter-ring-inner-edge.jpg"
            }
          }
        }
      }
    }
    ,"Saturn":
    {
      "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 2.5 ,"units": "degrees" }
      ,"orbital": { "period": 10747, "units": "days" }
      ,"location": { "x": 1433.5e6, "y": 0, "z": 0 }
      ,"Body":
      {
        "name": "Saturn"
        ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 26.7 ,"units": "degrees" }
        ,"rotation": { "period": 10.7, "units": "hours" }
        ,"Avatar":
        {
          "diameter": 120536
          ,"density": 687
          ,"mass": 568e24
          ,"texture": "res/images/astro/saturnmap.jpg"
          ,"Ring":
          {
            "height": 1000
            ,"innerRadius": 66900
            ,"outerRadius": 181000
            ,"transparency": 0.1
            ,"textures":
            {
              "face": "res/images/astro/saturnringcolor.jpg"
              ,"outside": "res/images/astro/saturn-ring-outer-edge.jpg"
              ,"inside": "res/images/astro/saturn-ring-inner-edge.jpg"
            }
          }
        }
      }
    }
avatar
Nevyn
Admin

Posts : 811
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Simple Orbiter

Post by Nevyn on Thu Aug 27, 2015 5:36 am

Code:

,"Uranus":
{
  "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.8 ,"units": "degrees" }
  ,"orbital": { "period": 30589, "units": "days" }
  ,"location": { "x": 2872.5e6, "y": 0, "z": 0 }
  ,"Body":
  {
    "name": "Uranus"
    ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 97.8 ,"units": "degrees" }
    ,"rotation": { "period": -17.2, "units": "hours" }
    ,"Avatar":
    {
      "diameter": 51118
      ,"density": 1271
      ,"mass": 86.8e24
      ,"texture": "res/images/astro/uranusmap.jpg"
      ,"Ring":
      {
        "height": 1000
        ,"innerRadius": 41837
        ,"outerRadius": 51149
        ,"transparency": 0.1
        ,"textures":
        {
          "face": "res/images/astro/uranusringcolour.jpg"
          ,"outside": "res/images/astro/uranus-ring-outer-edge.jpg"
          ,"inside": "res/images/astro/uranus-ring-inner-edge.jpg"
        }
      }
    }
    ,"Orbitals":
    {
      "Miranda":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 4.22 ,"units": "degrees" }
        ,"orbital": { "period": 1.413479, "units": "days" }
        ,"location": { "x": 129390, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Miranda"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0027 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 240
            ,"dimensions": { "x": 240, "y": 234.2, "z": 232.9 }
            ,"density": 1200
            ,"mass": 0.066e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Ariel":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.31 ,"units": "degrees" }
        ,"orbital": { "period": 2.520379, "units": "days" }
        ,"location": { "x": 191020, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Ariel"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0034 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 581
            ,"dimensions": { "x": 581.1, "y": 577.9, "z": 577.7 }
            ,"density": 1670
            ,"mass": 13.5e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Umbriel":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.36 ,"units": "degrees" }
        ,"orbital": { "period": 4.144177, "units": "days" }
        ,"location": { "x": 266300, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Umbriel"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0050 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 584.7
            ,"density": 1400
            ,"mass": 11.7e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Titania":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.14 ,"units": "degrees" }
        ,"orbital": { "period": 8.705872, "units": "days" }
        ,"location": { "x": 435910, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Titania"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0022 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 788.9
            ,"density": 1710
            ,"mass": 35.2e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Oberon":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.10 ,"units": "degrees" }
        ,"orbital": { "period": 13.463239, "units": "days" }
        ,"location": { "x": 583520, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Oberon"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0008 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 761.4
            ,"density": 1630
            ,"mass": 30.1e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Cordelia":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.08 ,"units": "degrees" }
        ,"orbital": { "period": 0.335034, "units": "days" }
        ,"location": { "x": 49770, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Cordelia"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0003 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 20
            ,"density": 1000
            ,"mass": 0.01e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Ophelia":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.10 ,"units": "degrees" }
        ,"orbital": { "period": 0.376400, "units": "days" }
        ,"location": { "x": 53790, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Ophelia"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0099 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 21
            ,"density": 1000
            ,"mass": 0.01e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Bianca":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.19 ,"units": "degrees" }
        ,"orbital": { "period": 0.434579, "units": "days" }
        ,"location": { "x": 59170, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Bianca"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0009 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 26
            ,"density": 1000
            ,"mass": 0.01e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Cressida":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.01 ,"units": "degrees" }
        ,"orbital": { "period": 0.463570, "units": "days" }
        ,"location": { "x": 61780, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Cressida"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0004 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 40
            ,"density": 1000
            ,"mass": 0.01e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Desdemona":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.11 ,"units": "degrees" }
        ,"orbital": { "period": 0.473650, "units": "days" }
        ,"location": { "x": 62680, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Desdemona"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0001 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 32
            ,"density": 1000
            ,"mass": 0.01e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Juliet":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.07 ,"units": "degrees" }
        ,"orbital": { "period": 0.493065, "units": "days" }
        ,"location": { "x": 64350, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Juliet"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0007 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 47
            ,"density": 1000
            ,"mass": 0.01e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
    }
  }
}
,"Neptune":
{
  "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 1.8 ,"units": "degrees" }
  ,"orbital": { "period": 59800, "units": "days" }
  ,"location": { "x": 4495.1e6, "y": 0, "z": 0 }
  ,"Body":
  {
    "name": "Neptune"
    ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 28.3 ,"units": "degrees" }
    ,"rotation": { "period": 16.1, "units": "hours" }
    ,"Avatar":
    {
      "diameter": 49528
      ,"density": 1638
      ,"mass": 102e24
      ,"texture": "res/images/astro/neptunemap.jpg"
      ,"Ring":
      {
        "height": 1000
        ,"innerRadius": 41900
        ,"outerRadius": 62933
        ,"transparency": 0.1
        ,"textures":
        {
          "face": "res/images/astro/uranusringcolour.jpg"
          ,"outside": "res/images/astro/uranus-ring-outer-edge.jpg"
          ,"inside": "res/images/astro/uranus-ring-inner-edge.jpg"
        }
      }
    }
    ,"Orbitals":
    {
      "Naiad":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 4.74 ,"units": "degrees" }
        ,"orbital": { "period": 0.294396, "units": "days" }
        ,"location": { "x": 48227, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Naiad"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0003 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "diameter": 48
            ,"dimensions": { "x": 48, "y": 30, "z": 26 }
            ,"density": 1000
            ,"mass": 0.002e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Thalassa":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.21 ,"units": "degrees" }
        ,"orbital": { "period": 0.311485, "units": "days" }
        ,"location": { "x": 50075, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Thalassa"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0002 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "diameter": 54
            ,"dimensions": { "x": 54, "y": 50, "z": 26 }
            ,"density": 1000
            ,"mass": 0.004e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Despina":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.07 ,"units": "degrees" }
        ,"orbital": { "period": 0.334655, "units": "days" }
        ,"location": { "x": 52526, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Despina"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0001 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "diameter": 90
            ,"dimensions": { "x": 90, "y": 74, "z": 64 }
            ,"density": 1000
            ,"mass": 0.02e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Galatea":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.05 ,"units": "degrees" }
        ,"orbital": { "period": 0.428745, "units": "days" }
        ,"location": { "x": 61953, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Galatea"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0001 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "diameter": 102
            ,"dimensions": { "x": 102, "y": 92, "z": 72 }
            ,"density": 1000
            ,"mass": 0.04e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Larissa":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.20 ,"units": "degrees" }
        ,"orbital": { "period": 0.554654, "units": "days" }
        ,"location": { "x": 73548, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Larissa"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0014 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "diameter": 108
            ,"dimensions": { "x": 108, "y": 102, "z": 84 }
            ,"density": 1000
            ,"mass": 0.05e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"S/2004 N1":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0 ,"units": "degrees" }
        ,"orbital": { "period": 0.950, "units": "days" }
        ,"location": { "x": 105300, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "S/2004 N1"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 18
            ,"density": 1000
            ,"mass": 0.1e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Proteus":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.04 ,"units": "degrees" }
        ,"orbital": { "period": 1.122315, "units": "days" }
        ,"location": { "x": 117647, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Proteus"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.0004 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "diameter": 220
            ,"dimensions": { "x": 220, "y": 208, "z": 202 }
            ,"density": 1000
            ,"mass": 0.5e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Triton":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 157.345 ,"units": "degrees" }
        ,"orbital": { "period": -5.876854, "units": "days" }
        ,"location": { "x": 354760, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Triton"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.000016 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 1353.4
            ,"density": 2050
            ,"mass": 214e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Nereid":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 7.23 ,"units": "degrees" }
        ,"orbital": { "period": 360.13619, "units": "days" }
        ,"location": { "x": 5513400, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Nereid"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.7512 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 170
            ,"density": 1000
            ,"mass": 0.3e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Halimede":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 134.1 ,"units": "degrees" }
        ,"orbital": { "period": -1879.7, "units": "days" }
        ,"location": { "x": 15730000, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Halimede"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.571 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 30
            ,"density": 1000
            ,"mass": 0.001e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Sao":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 48.5 ,"units": "degrees" }
        ,"orbital": { "period": 2914.1, "units": "days" }
        ,"location": { "x": 22420000, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Sao"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.293 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 20
            ,"density": 1000
            ,"mass": 0.001e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Laomedeia":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 34.7 ,"units": "degrees" }
        ,"orbital": { "period": 3167.9, "units": "days" }
        ,"location": { "x": 23570000, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Laomedeia"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.424 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 20
            ,"density": 1000
            ,"mass": 0.001e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Psamathe":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 137.4 ,"units": "degrees" }
        ,"orbital": { "period": -9115.9, "units": "days" }
        ,"location": { "x": 46700000, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Psamathe"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.450 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 20
            ,"density": 1000
            ,"mass": 0.001e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
      ,"Neso":
      {
        "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 132.6 ,"units": "degrees" }
        ,"orbital": { "period": -9374.0, "units": "days" }
        ,"location": { "x": 48390000, "y": 0, "z": 0 }
        ,"Body":
        {
          "name": "Neso"
          ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.495 ,"units": "degrees" }
          ,"rotation": { "period": 100, "units": "hours" }
          ,"Avatar":
          {
            "radius": 30
            ,"density": 1000
            ,"mass": 0.0005e20
            ,"texture": "res/images/astro/moonmap1k.jpg"
          }
        }
      }
    }
  }
}
,"Pluto":
{
  "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 17.2 ,"units": "degrees" }
  ,"orbital": { "period": 90588, "units": "days" }
  ,"location": { "x": 5870.0e6, "y": 0, "z": 0 }
  ,"Body":
  {
    "name": "Pluto"
    ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 122.5 ,"units": "degrees" }
    ,"rotation": { "period": -153.3, "units": "hours" }
    ,"Avatar":
    {
      "diameter": 2390
      ,"density": 1830
      ,"mass": 0.0131e24
      ,"texture": "res/images/astro/plutomap1k.jpg"
    }
  }
}
avatar
Nevyn
Admin

Posts : 811
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Simple Orbiter

Post by Nevyn on Thu Aug 27, 2015 7:58 pm

I thought it might help if I explained a little bit about this JSON structure since it loses some of the explicit nature from the XML.

Here we have the definition of Mercury, which is a very simple orbit with 1 body. The outside object (here being set to the "Mercury" property) represents the orbit, not the planet (mostly). It can contain 4 properties: "tilt", "orbital", "location" and "Body".

    "Mercury":
    {
      "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 7 ,"units": "degrees" }
      ,"orbital": { "period": 88, "units": "days" }
      ,"location": { "x": 57.9e6, "y": 0, "z": 0 }
      ,"Body":
      {
        "name": "Mercury"
        ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0.01 ,"units": "degrees" }
        ,"rotation": { "period": 1407.6, "units": "hours" }
        ,"Avatar":
        {
          "diameter": 4879
          ,"density": 5427
          ,"mass": 0.330e24
          ,"texture": "res/images/astro/mercurymap.jpg"
        }
      }
    }

The "tilt" property is an object containing an axis rotation which is specified by the x, y, z of the axis and the a value for the angle. The "units" property can be used to specify "degrees" or "radians" for convenience.

The "orbital" property specifies the "period" of the orbit and the "units" can be "days" or "hours".

The "location" property is just the x, y, z position of the orbit which is always specified in the x dimension here for simplicity. These really need to be altered so that the correct relative positions of the planets can be applied (for a given time). It may end up being easier to specify another property which is the initial rotation of the orbit so that we can start at a known position and then move it to where it should be. This is easier because some of the other properties can be set knowing that we are in a certain orientation.

The "Body" property contains the definition of the planet itself. All values specified inside the Body object are relative to the Orbit.

The "name" property just gives us the name of the planet and this is a bit annoying because we already specified the name at the top level. I don't like specifying the same information multiple times because then you have to keep them in sync and errors are often created. However, I wanted the Body object to be self-contained so I have left it in there.

The "tilt" property is an axis rotation just like with the Orbit but is applied to the planet itself.

The "rotation" property is just like the "orbital" property of the Orbit, and applies a rotation to the planet.

The "Avatar" property is an object containing the definition of the body itself. This is used to build the 3D object to represent the planet. There are some choices in how you specify the properties of the Avatar.

The "radius" property will set the size of the body.
The "diameter" property will also set the size of the body.
The "dimensions" property can be used to specify the x, y, and z dimensions when the body is not a normal spherical shape. This is only useful for moons when we know the dimensions. It is specified like this: "dimensions": { "x": N, "y": N, "z": N }.
Only use one of them, although you can leave in a radius or diameter if you specify the dimensions, as it will be used as a fall-back.

The "density" property specifies the density of the body.

The "mass" property specifies the mass.

These are the mainstream values for these parameters, although we may look into making them Mathis values if we get it running on his math.

The "texture" property tells the system what image to apply to the body. Leave these in your definitions but I will need to set them to what images I have. I have already specified all the textures for the main planets. Some moons have their own texture but most just use a generic one.

If we look at the definition of the Earth, then we find some differences to Mercury.
    
    ,"Earth":
    {
      "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 0 ,"units": "degrees" }
      ,"orbital": { "period": 365.2, "units": "days" }
      ,"location": { "x": 149.6e6, "y": 0, "z": 0 }
      ,"Body":
      {
        "name": "Earth"
        ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 23.4 ,"units": "degrees" }
        ,"rotation": { "period": 23.9, "units": "hours" }
        ,"Avatar":
        {
          "diameter": 12756
          ,"density": 5514
          ,"mass": 5.97e24
          ,"texture": "res/images/astro/earthmap1k.jpg"
        }
        ,"Orbitals":
        {
          "Moon":
          {
            "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": -18.255 ,"units": "degrees" }
            ,"orbital": { "period": 27.3, "units": "days" }
            ,"location": { "x": 378000, "y": 0, "z": 0 }
            ,"Body":
            {
              "name": "Moon"
              ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 27.3 ,"units": "degrees" }
              ,"rotation": { "period": 655.7, "units": "hours" }
              ,"Avatar":
              {
                "diameter": 3475
                ,"density": 3340
                ,"mass": 0.073e24
                ,"texture": "res/images/astro/moonmap1k.jpg"
              }
            }
          }
        }
      }
    }

The "Body" now has an "Orbitals" property which is used to specify moons. A moon uses the same structure as top level Orbits. You can add as many moons as you need to to a planet.

Looking at Jupiter, we find another difference which is a Ring.

    ,"Jupiter":
    {
      "tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 1.3 ,"units": "degrees" }
      ,"orbital": { "period": 4331, "units": "days" }
      ,"location": { "x": 778.6e6, "y": 0, "z": 0 }
      ,"Body":
      {
        "name": "Jupiter"
        ,"tilt": { "x": 1 ,"y": 0 ,"z": 0 ,"a": 3.1 ,"units": "degrees" }
        ,"rotation": { "period": 9.9, "units": "hours" }
        ,"Avatar":
        {
          "diameter": 142984
          ,"density": 1326
          ,"mass": 1898e24
          ,"texture": "res/images/astro/jupiter2_1k.jpg"
          ,"Ring":
          {
            "height": 1000
            ,"innerRadius": 100000
            ,"outerRadius": 224900
            ,"transparency": 0.2
            ,"textures":
            {
              "face": "res/images/astro/jupiter-ring.jpg"
              ,"outside": "res/images/astro/jupiter-ring-outer-edge.jpg"
              ,"inside": "res/images/astro/jupiter-ring-inner-edge.jpg"
            }
          }
        }
      }
    }

The "Ring" property is added to the "Avatar" and has the following properties.

The "height" property is not really a physical parameter but is used to make sure the rings are visible. A value of 1000 seems to work well in my old app. I will see how well it works when I get to building rings in the new web version.

The "innerRadius" property specifies the inner boundary of the rings, that is, how close they are to their planet.

The "outerRadius" property specifies the outer boundary.

The "transparency" value allows you to make the ring transparent.

The "textures" property is an object containing 3 textures: "face", "outside" and "inside".

The "face" texture is the main one you will see as it is applied to the top and bottom of the rings.

The "outside" texture is applied to the edge of the ring and is also often visible.

The "inside" texture is applied to the inner edge of the ring and is usually only visible when moving in close to the planet.

I hope that helps you to understand what all these values mean. There are probably other parameters we could add and if you think there are then post it here and I will see how I can use it.

I had some problems with this data such as knowing the tilt values but not knowing what axis to apply them to. Mainstream data specifies the angle but this is not enough. I didn't dig too far into the data though so I may be missing something. Again, if you understand this data better than me then please speak up so I can fix it.
avatar
Nevyn
Admin

Posts : 811
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Simple Orbiter

Post by LongtimeAirman on Thu Aug 27, 2015 9:34 pm

Nevyn, Thanks for your confidence. I've saved your data code to a JSON file that my NetBeans IDE 7.4 says is OK. Tilt - tilt! The additional info is appreciated. I'll review it for consistency.

LongtimeAirman
Admin

Posts : 612
Join date : 2014-08-10

View user profile

Back to top Go down

JSON Initial Review

Post by LongtimeAirman on Fri Aug 28, 2015 9:40 pm

Nevyn,

You had this solar system working originally on another system and in XML. You haven’t produced a working JAVA translation/application yet. You’re providing a simple JSON file for starters. The Charge Field will come later. Maybe this exercise will be good for me.

There is one Sun, the single property of “CentralBodies”. The 9 planets are “Orbitals”, on the same level as “CentralBodies”. Likewise, moons are “Orbitals”, a property of the planets’ “Body”. The Earth “Body” has 1 “Orbitals” - the Moon; Uranus has 11 “Orbitals”; Neptune has 14. That makes a total of 36 bodies (1 sun, 9 planets and 26 moons). The 4 gas giants have “Rings”.

The Sun:
"CentralBodies": {"Sun": {"tilt": { }, "rotation": { }, "Avatar": { }}}

A Planet:
"CentralBodies": { }, "Orbitals”: {“Mercury”: {"tilt": { }, "orbital": { }, "location": { },
"Body": {"name": “Mercury “, "tilt": { }, "rotation": { },"Avatar": { }}}}

A Moon:
"CentralBodies": { }, "Orbitals”: {Earth: {"tilt": { }, "orbital": { }, "location": { },
"Body": {"name": "Earth", "tilt": { }, "rotation": { },"Avatar": { }, “Orbitals”: {“Moon”: {"tilt": { }, "orbital": { }, "location": { }, “Body”: {"name": “Moon “, "tilt": { }, "rotation": { },"Avatar": { }}}}}}}

Granted, this “structural” comparison may be beside the point, as I have close to zero working knowledge, but it sure seems unnecessarily complicated, or inefficient to me. It seems, that in order to define the “Moon” “orbital”, you have to go through the structure of an “Orbitals”, an “orbital”, and another “Orbitals”. Also, 2 “Body”s, …, and 4 “tilt”s. Please assure me that branching structures with a single variable name doesn’t corrupt the variable assignment.

I’ve got three.js open looking for some orbital mechanics functions. It’s fun, but no joy yet. My browser says it will disown me if I try to download the minified library. Or is there another source you can direct me to?

The "tilt" property is an object containing an axis rotation which is specified by the x, y, z of the axis and the a value for the angle. The "units" property can be used to specify "degrees" or "radians" for convenience.
How can a single coordinate yield a tilt? What is the “a value”? "a" appears 71 times in all the "tilt" properties.

The "location" property is just the x, y, z position of the orbit which is always specified in the x dimension here for simplicity.
Always specified in the x dimension (?) Is the x dimension some kind of starting position?

The "radius" property will set the size of the body.
The "diameter" property will also set the size of the body.
The "dimensions" property can be used to specify the x, y, and z dimensions when the body is not a normal spherical shape. This is only useful for moons when we know the dimensions. It is specified like this: "dimensions": { "x": N, "y": N, "z": N }.
Only use one of them, although you can leave in a radius or diameter if you specify the dimensions, as it will be used as a fall-back.

I have difficulty interpreting this. I’ll just list what I see. In the 36 separate "Avatar" objects: there are 16 instances of “diameter”, 6 of which are followed by “dimensions”; and there are 20 instances of “radius”, 2 of which are followed by “dimensions”.

The "density" property specifies the density of the body.
Varying from a low of 687 for Saturn, 1408 for the Sun, and the high, 5514 for the Earth. No units specified.

The "mass" property specifies the mass.
The mass low is Neso – 0.0005e20, Earth – 5.97e24, Jupiter - 1898e24, and the Sun - 1988500e24. No units specified.

That’s my first run through. Straightforward enough even without comments.

I must say. Let’s start by commenting out the moons, rings, and textures and get the Sun and planets working.

LongtimeAirman
Admin

Posts : 612
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Simple Orbiter

Post by Nevyn on Sat Aug 29, 2015 1:04 am

LongtimeAirman wrote:
Granted, this “structural” comparison may be beside the point, as I have close to zero working knowledge, but it sure seems unnecessarily complicated, or inefficient to me. It seems, that in order to define the “Moon” “orbital”, you have to go through the structure of an “Orbitals”, an “orbital”, and another “Orbitals”. Also, 2 “Body”s, …, and 4 “tilt”s. Please assure me that branching structures with a single variable name doesn’t corrupt the variable assignment.

I converted my existing XML file into JSON and the quickest, easiest, less prone to error way of doing that was to just use the XML element names as JSON object keys. I did change a few where it was more convenient to do it slightly differently but not many. The XML parser that I wrote for it used the structure to determine when to create certain types of objects for the 3D scene.

It is a bit more complicated than it might be. I did see some areas that I thought could be changed, however, as I work with it I often find that I need to keep groupings that I thought I might get rid of. Think of it as a hierarchy where each level is inside of its parent so anything that alters the parent also alters the child because the child's values are relative to its parent.

Solar System
 Stars
 Orbits
   Planet
     Orbits
       Moon

An Orbit takes care of placing the body at the correct radius and rotates it around the orbital path.
A Planet takes care of its own tilt and axial rotation and its Moons.
A Moon just takes care of its own tilt and axial rotation.

The way I have implemented it in the new web version is with 3 levels: Model, Orbit and Body. But really, I only need Body and Orbit because a Body can have Orbits which have a Body which can have Orbits, ad infinitum. I had the CentralBodies object in there to handle binary star systems, etc, where multiple bodies are treated as a single gravitational entity.

Both Orbit and Body have internal levels though. An Orbit has a level for its tilt, a level to rotate and a level to move the body out to the correct radius. This allows us to work with any of these levels independent of any others. If I want to adjust the tilt, then I can do that and everything contained in the tilt will be affected. Similarly, when I am working with a planet, then I am working in coordinates relative to the center of that planet and I don't have to think about where it is in the solar system. Each group, or level, provides its own coordinate system.

LongtimeAirman wrote:
I’ve got three.js open looking for some orbital mechanics functions. It’s fun, but no joy yet. My browser says it will disown me if I try to download the minified library. Or is there another source you can direct me to?

Don't listen to your browser, it is just winging because you are trying to download code which could be malicious.

LongtimeAirman wrote:
The "tilt" property is an object containing an axis rotation which is specified by the x, y, z of the axis and the a value for the angle. The "units" property can be used to specify "degrees" or "radians" for convenience.
How can a single coordinate yield a tilt? What is the “a value”? "a" appears 71 times in all the "tilt" properties.

An axis rotation combines a vector to specify the axis and an angle to rotate. The x, y, z values specify a vector which gives us a line from 0, 0, 0 to that point. The a value specifies the angle which we will rotate around the axis. If we wanted to rotate something about the Y axis by Pi, then we would use this axis rotation: { "x": 0, "y": 1, "z": 0, "a": 3.14 }. Rotate about the Z axis: { "x": 0, "y": 0, "z": 1, "a": 3.14 }. We can use any axis we like so you can rotate an object in any way you need to.

We take a planet, say, and it has its own coordinate system where X points to the right, Y points up and Z points out of the screen. If we give it a tilt of { "x": 1, "y": 0, "z": 0, "a": 3.14 } then after that is applied, the Y axis will now point down and the Z axis will now point into the screen because we have rotate the whole coordinate system around the X axis by 180 degrees.

LongtimeAirman wrote:
The "location" property is just the x, y, z position of the orbit which is always specified in the x dimension here for simplicity.
Always specified in the x dimension (?) Is the x dimension some kind of starting position?

It is not the X dimension itself that it special, just that I happen to choose it. I could have used the Z axis, just as easily. Basically what I have done is set their orbital radius using that dimension. I could specify that value as just the radius and the application would then choose a way to use it (which would be to put in on the X or Z axis) and you would be none-the-wiser. I have used all 3 dimensions because it allows you to set the relative positions of all the planets (or moons) but I think I will change it to be just a radius value, now that I think about it.

It can be useful knowing that the body will start at a known position (such as on the X axis) because we can then set other parameters such as its tilt, orientation, etc, and know what results to expect.

LongtimeAirman wrote:
The "radius" property will set the size of the body.
The "diameter" property will also set the size of the body.
The "dimensions" property can be used to specify the x, y, and z dimensions when the body is not a normal spherical shape. This is only useful for moons when we know the dimensions. It is specified like this: "dimensions": { "x": N, "y": N, "z": N }.
Only use one of them, although you can leave in a radius or diameter if you specify the dimensions, as it will be used as a fall-back.

I have difficulty interpreting this. I’ll just list what I see. In the 36 separate "Avatar" objects: there are 16 instances of “diameter”, 6 of which are followed by “dimensions”; and there are 20 instances of “radius”, 2 of which are followed by “dimensions”.

Yeah, this bit is a bit tricky. Basically, there are 3 ways to specify the size of a body. You can use the radius or diameter properties to create a spherical body or you can use the dimensions property to specify the size in all 3 dimensions.

The data I used had various values, some radius, some diameter and even some moons that had length, breadth and height values so I implemented all 3 ways as it was easier to change the name of a value than to recalculate the values when building the config file. This also meant that my config file data matched the source data so it was easier to compare them for mistakes.

LongtimeAirman wrote:
That’s my first run through. Straightforward enough even without comments.

I must say. Let’s start by commenting out the moons, rings, and textures and get the Sun and planets working.

I already have a working system, albeit with a few issues. The Sun, planets and moons are all done since they all use orbits so there is no difference between a moon and a planet and technically, a moon could have its own moon which could have its own moon, etc. I have not implemented rings yet as these require careful creation so that the textures are applied correctly. I have used a different navigation system which lets you fly through the solar system. It can be a pain at times but is adequate. I have created a ring to show the orbital paths and each body has some lines through it to show its axes. Distance is a big problem so I have values that allow me to scale them which brings the planets closer in to the center. Same with the moons but these are independent as having them the same causes a lot of moons to move inside of their planet and hence, are not visible.

I'll try to get it up on the web tomorrow along with some new changes for the Proton Viewer which I will send you the source code for. I went to send it to you the other day but found that it was not in good shape at the time as I was half way through some changes.


Last edited by Nevyn on Sun Aug 30, 2015 10:50 pm; edited 1 time in total
avatar
Nevyn
Admin

Posts : 811
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Simple Orbiter

Post by Nevyn on Sat Aug 29, 2015 1:10 am

I will also add that a lot of the current structure around orbits will disappear in a Mathis system. Once we have the math in place, all of this will be reduced to just a bunch of objects. We won't even need to specify the sun as something special because it will just be the biggest entity in the field so all calculations will be based from it.

That's the dream and the only difference between the dream and reality is a lot of hard work.
avatar
Nevyn
Admin

Posts : 811
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Simple Orbiter

Post by Cr6 on Sat Aug 29, 2015 3:20 pm

Hey Nevyn,

I came across this chrome experiment with three.js:

http://stars.chromeexperiments.com/


Cr6
Admin

Posts : 677
Join date : 2014-08-09

View user profile http://milesmathis.the-talk.net

Back to top Go down

Re: Simple Orbiter

Post by Nevyn on Sat Aug 29, 2015 9:20 pm

That's a pretty cool app, Cr6. I couldn't move around in it, only rotate the camera but I did like the effect they have on the sun. I might have to look into doing that. It's unnecessary, but cool. I also stole the way they show the orbital path using spheres. I was using lines which are computationally less expensive but I did like the way those spheres looked, so now I have that too.
avatar
Nevyn
Admin

Posts : 811
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Simple Orbiter

Post by LongtimeAirman on Sat Aug 29, 2015 9:54 pm

My only complaint of 100,000 stars - the scale transitions are inaccurate overlaps. Otherwise, those are a lot of particles to keep (the impression of) tracking. Those dashed rings at the solar system level are nice.

The Video https://www.youtube.com/watch?v=57P8julAaRE "5yrs of three.js" presented by Ricardo gave me a better idea where they are with respect to "product development".  

I downloaded \mrdoob-three.js-r71-5-gd6384d2\mrdoob-three.js-d6384d2\examples. I can now begin to understand what I'm looking at, functionally. I still don't know if I have all that I need to use their examples.

I'm about saturated with looking at many .js, videos, demos, examples, games, ... for the time being.

LongtimeAirman
Admin

Posts : 612
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Simple Orbiter

Post by Nevyn on Sat Aug 29, 2015 11:29 pm

Start very small, Airman, and work your way up. Copy one of the simple examples and reduce it back to the bare essentials and then start adding in your own stuff. You will get very frustrated when things don't work and you can't figure out why, but when you do, that's wisdom growing and it feels good.

In the beginning you will probably have multiple errors so you may fix one of them but still nothing shows, so you don't realise you have it correct. This is the most frustrating time so don't be afraid to ask for guidance once you have reached that point.

I have found that it is easiest to search for solutions to problems with three by prefixing 'three.js' to the front of any search. Obviously, searching for 'three' won't get you what you want. If you see a search result that is at stackoverflow.com, go to that one first. Brilliant site for programming problems.
avatar
Nevyn
Admin

Posts : 811
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Simple Orbiter

Post by Nevyn on Sun Aug 30, 2015 10:46 pm

I am having trouble with large numbers in this app which are causing scaling issues. I noticed the scaling problem early on as some planets were being squashed in the radial direction out from the sun. I checked the code to make sure I wasn't doing some weird scale somewhere and it wasn't using them at all (I do scale some values but this is not the same as applying a 3D scale). I didn't really know what the problem was but now I have accidentally found an important clue.

I was working on another problem which is distance. The solar system is so large that it is difficult to move around in. I decided to add some keyboard bindings that would place the user at the current location of the planets: 1 for Mercury, 2 for Venus, 3 for Earth, etc. I was playing around with different places I could put a camera inside of the planets levels which would allow the user to rotate with the planet or to sit outside of that rotation and see it spin, etc.

Anyway, to cut a long story short, I was using the camera at Neptune, which has a lot of moons which all looked like ellipses with the scaling issue, but this time they were all spherical. That made me realise that the camera I was using was part of the scaling issue. It isn't really the camera itself but its reference point.

The starting camera (which I call a floating camera) is part of the top level scene group so it is referenced from 0, 0, 0. Therefore, Neptune is a long way away from that reference point. However, if I am using a camera inside of Neptune's groups, then the camera and the planet share the same coordinate system reference (or close enough) and the values for Neptune that the camera has to render are not very large.

So my best guess is that the numbers are being rounded slightly. This happens because numbers have to fit within a certain size limit (8bit, 32bit, 64bit, etc) and you can only store so much data in a limited space so the variable stores what it can, not what you asked it to. This is rarely a problem unless dealing with very large coordinates, like I am here.

Note that it is possible to calculate using numbers that are not limited by size but they are not fast calculations and are not feasible for 3D scene graph processing where you need to make lots and lots of calculations every frame. Interestingly, the Java3D API I use in Java had a mix of the 2 where the top level group was called a Locale which had Hi-res coordinates stored in arbitrarily sized numbers but all data within a Locale used fixed size (32 or 64bit) numbers. I am thinking I may need to do the same here such that each Locale has its own camera and as the user moves across the boundary of one Locale to another, it will switch camera seamlessly.

I don't expect you guys to be able to help solve this one, I just wanted to keep you up-to-date and also it helps me to write it out and explain it.
avatar
Nevyn
Admin

Posts : 811
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Version 0.1

Post by Nevyn on Mon Aug 31, 2015 8:33 am

I have uploaded the Solar System Viewer. It currently provides an animated solar system containing Sun, Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune and Pluto. The Earth, Uranus and Neptune have moons but none of the others. None of the ringed planets have their rings as these needs to be custom built.

The navigation controls are a bit complicated. Essentially you have a space ship with pitch and yaw capabilities through the mouse and pitch, roll and yaw through the keyboard. Click and drag the mouse to adjust the pitch and yaw. The arrow keys will also adjust these. The Q and E keys will roll and W, S, A, D, R, F are forward, backward, left, right, up and down. The shift key causes movement to be small, the control key makes it large.

You can change the active camera using the number keys. 1 - 9 will send you to a planet, hold down the shift key to go to a higher level that is not rotating with the planet. The 0 key will take you back to the floating camera you start in.

The tilde '~' key can be used to stop/start time. You can also adjust the rate of time in the controls. This has a very large range so it is a bit hard to use as a slider. You can enter a value into the text field.

The app shows various helpers such as orbital path markers, planet and moon tether lines, the local axes of a body which can all be turned on and off in the controls. You can also set the color of most things too.

There are controls that adjust the size of things. These can be used to extremes as some of the settings affect each other. For example, scaling up the radius of a planet will also be affected by scaling up its size because the radius is inside of the size scale. Moons are also inside of the size scale of their parent planet and will scale even further. I have limited access to some of the controls to stop things getting too far out of hand.
avatar
Nevyn
Admin

Posts : 811
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Version 0.2

Post by Nevyn on Tue Sep 01, 2015 8:56 am

I have update the Solar System Viewer with a few more controls to change the orbital paths, enable/disable tethers, etc. I have implemented rings now which look pretty good and I have also implemented dimensions specified on a body.
avatar
Nevyn
Admin

Posts : 811
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Simple Orbiter

Post by Cr6 on Sat Sep 05, 2015 2:33 am

Hi Nevyn,

Just wanted to say this is fun to work with and looks good... feels like I'm in a spacecraft at times.

BTW, I found that I often get a "disco lights" effect after touching the arrow keys on the keyboard. I figured that it was a looped-scaling issue.

Really, impressive!

Cr6
Admin

Posts : 677
Join date : 2014-08-09

View user profile http://milesmathis.the-talk.net

Back to top Go down

Re: Simple Orbiter

Post by LongtimeAirman on Sat Sep 05, 2015 11:22 pm

Nevyn, Smashing!

Nit Picking:

1: Using the quick numbers (1-9), most of the planets have “jitters” - the image center moves slightly . Jupiter and Saturn are the most stable. Mars is annoying with an any-direction wander of about a millimeter (on my 14” wide screen), Uranus and Neptune are worse, and Pluto jitters the most – over an inch in any direction, and many times a second. The sun and satellite tethers jitter along with the planet. When I use the shift (1-9), the jitter seems to be vertical – in line with the sun tether. Round-off errors associated with your largest distances seems likely to me.

2: I don’t have a mouse and so cannot really steer the viewpoint.  Just single finger movement; if I use two or more, the browser screen, controls and title – zoom.

I’ll just break down and get a mouse. Best excuse yet.

LongtimeAirman
Admin

Posts : 612
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Simple Orbiter

Post by Nevyn on Sun Sep 06, 2015 5:03 pm

I've noticed the jittering. It is mostly just the outer planets for me,
Pluto being the worst. I think this is caused by rounding errors, as you say, since the orbits are implemented as a rotation from the center of the system. I have had a few thoughts about how to fix it but it relies on giving the planets a velocity rather than a rotational orbit so it leads into using gravity math very quickly. I thought it best to make it work on Miles math rather than mainstream so I haven't gone down that path yet.

I've been a little side-tracked this week. When I developed the rings for the planets it reminded me of the code I wrote for that (and a few other things) in my original desktop version which was used to generate low level geometry. I have been creating an extension module for THREEJS that allows you to build 3D geometry by using 2D pieces. You create the small 2D blocks and then apply transformations (through matrices) to them to move them into the position you want, clone it and add it to an array and then manipulate it again to move it to the next spot, clone it again to add the the array, etc, etc. It supports geometry types point, line, line fan, line strip, triangle, triangle fan, triangle strip, quad, quad fan, quad strip, circle, cone, cylinder. I've also been treating it a good opportunity to learn about creating modules in Javascript and also I've started to use a documentation app (JSDoc3) that will generate HTML pages from the source code for documentation.
avatar
Nevyn
Admin

Posts : 811
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum