# Virtual Solar System in Jave3D and Swing

• (3 Pages)
• 1
• 2
• 3

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

### #31 PGR

Reputation: 13
• 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.y = d * 0d;
m.location = loc;
m.BLocation = new BigVector3d(loc);

vel.y = s * 0d;
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.

### #32 jon.kiparsky

• Chinga la migra

Reputation: 10726
• Posts: 18,356
• 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.

### #33 PGR

Reputation: 13
• 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.