Virtual Solar System in Jave3D and Swing

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

32 Replies - 15423 Views - Last Post: 02 March 2015 - 04:35 PM

#31 PGR  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 59
  • Joined: 10-January 11

Re: Virtual Solar System in Jave3D and Swing

Posted 26 February 2015 - 10:34 PM

I'm redoing the way i add planets so that I can add velocity. I added a degree and a distance and then needed to calculate the vector (3d velocity) from the speed. I tried multiplying the speed by the cos/sin of the angle. Um, it looks like it works.
//set deg from a table or something
//in Java3D, y axis is virtical (solor polar north/south)
loc.x = d * Math.cos(Math.toRadians(deg));
loc.y = d * 0d;
loc.z = d * Math.sin(Math.toRadians(deg));
m.location = loc;
m.BLocation = new BigVector3d(loc);

vel.x = s * Math.cos(Math.toRadians(deg));
vel.y = s * 0d;
vel.z = s * Math.sin(Math.toRadians(deg));
m.velocity = vel;
m.BVelocity = new BigVector3d(vel);

System.out.println("speed-(" + m.getName() + ") deg=" + deg + ", m.speed=" + m.speed + ", " + m.velocity);


It looks like it worked.
speed-(Mercury) deg=33.28212666754814, m.speed=47.362, (39.59361786320304, 0.0, 25.990468801132636)
speed-(Venus) deg=124.84674071001994, m.speed=35.02, (-20.00984156281031, 0.0, 28.74033125472338)
speed-(Earth) deg=175.20963562356025, m.speed=29.78, (-29.675976004391263, 0.0, 2.4869355011326677)
speed-(Mars) deg=182.424393829827, m.speed=24.077, (-24.055448939156463, 0.0, -1.0184818779125633)
speed-(Ceres) deg=157.12463960953679, m.speed=17.905, (-16.49681937987305, 0.0, 6.960170640713131)
speed-(Jupiter) deg=319.20587316735356, m.speed=13.07, (9.894800748796571, 0.0, -8.53919306150264)
speed-(Saturn) deg=245.62111741206667, m.speed=9.69, (-3.9997292125102355, 0.0, -8.825999446328572)
speed-(Uranus) deg=25.865575369592115, m.speed=6.8, (6.118776388948967, 0.0, 2.9665763941015637)
speed-(Neptune) deg=49.22103124424015, m.speed=5.43, (3.5465648284034765, 0.0, 4.111785247058925)

It looks right for each quadrant.
Was This Post Helpful? 0
  • +
  • -

#32 jon.kiparsky  Icon User is online

  • Screw Trump (before he screws you)
  • member icon


Reputation: 10625
  • View blog
  • Posts: 18,182
  • Joined: 19-March 11

Re: Virtual Solar System in Jave3D and Swing

Posted 26 February 2015 - 10:44 PM

If you want to explore classical mechanics in computational terms, you might take a look at Structure and Interpretation of Classical Mechanics by Sussman and Wisdom. All of the code is in Scheme, which is a lisp dialect, but it looks like it covers a lot of what you're trying to invent for yourself.
Was This Post Helpful? 1
  • +
  • -

#33 PGR  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 59
  • Joined: 10-January 11

Re: Virtual Solar System in Jave3D and Swing

Posted 02 March 2015 - 04:35 PM

OK. I'll have a look at it. Thanks.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3