How to fix an issue with code pertaining to finding planets within a certain angle of each other

47 views Asked by At

The goal of my program is to see what planets come within a certain angle of each other, and stop the program. I have having issues specifically with the angle part. This program is on khan academy, here is the full program here.

I have two variables; var ranging = 10, grouping = 4;. The ranging is in degrees, and the grouping is any 4 planets that are within those 10 degrees, which you can change. The issue which is seen in the picture is only 2 planets fall within those 10 degrees, yet the red arc is saying there are 4.

enter image description here

So, the issue I am having is that the planets have degree values indicating their degrees on the solar plane, which are gathered into an array, to check if 4 planets are within the 10 degrees. It isn't necessarily the grouping or the array, it is how I am getting the solar angle. I have two ways to find the solar angle, through orbitDegree and the drawPlanet function, but since I added on to someone else's program, I overlooked it.

The angle used to draw the planets is needed in the grouping section, but I need to save those calculations so the AV section can access said value.

Line 234 - orbitDegree function and Line 295 is planet position. At around 320, there are a bunch of calculations for position.

But how do I save it in the grouping section?

Khan Academy uses a very basic library, so a good programmer should be able to attack this pretty well.

Thanks!

0

There are 0 answers