Trying to calculate Orbit figures with C# and 3D space

In summary: I have not heard of Spherical coordinate systems, but I am sure they exist. A spherical coordinate system is similar to a Cartesian coordinate system in that both have two coordinates, X and Y, but a spherical coordinate system also has a third coordinate, Z. The Z coordinate is usually just called the distance from the center of the sphere to the point you are measuring.In your code you are using 3d vectors and variables, so you need to specify which reference frame you are working in. You are working in the geocentric-equatorial reference frame, which has the origin at Earth's center, the X axis pointing to the vernal equinox, the Y axis pointing right hand rule, and
  • #1
Ajes
3
0
Hello smart people!

I am trying to make a simulation of an orbit with C#. I have come so far that I more or less only need a way to convert the apoapsis, periapsis and ascending node to 3D space vector3's. If it is possible, I want to avoid longitude and latitude?

Anyone have any suggestions?

my code: http://pastebin.com/5mbUVm99 [Broken]
 
Last edited by a moderator:
Astronomy news on Phys.org
  • #2
If it is possible, I want to avoid longitude and latitude?

Not sure what you mean by this, but at some point you will need spherical coordinates. From your code it looks like you have a good understanding of trigonometry so this shouldn't be a problem.

One possible cause of confusion is reference frames. Have you defined one? If so, which? If not, do you need help with that? Have you heard of geocentric-ecliptic, geocentric-equatorial and heliocentric-ecliptic frames?

The point is that latitude and longitude depend on Earth's rotation so it's not inertial. Totally understand you want to avoid that.
 
  • #3
Thank you for the quick reply :)

- I am a noob at Orbital Mechanics and stuff like this, but I can learn quickly if a subject interests me :D

I was hoping that a Quaternion was enough for the rotation of the primary, to calculate positions and degrees from. (even if I only know that a Quaternion is a rotation in 3d space)

Im not even sure what a reference frame is, On some wikipages I saw a reference plane, that was a circle around equator. - I have not defined one :/

I have not heard of any of these: geocentric-ecliptic, geocentric-equatorial and heliocentric-ecliptic frames - but maybe the equatorial is the equator plane I saw on the wiki page? :D
 
  • #4
Ok, it's much simpler than it seems, but extremely important if you want to work with x,y,z and define angles.

In the celestial sphere astronomers define the celestial equator (a projection of Earth's equator) and the ecliptic, which is the apparent motion of the Sun through the sphere during the year. Of course, the ecliptic is basically a projection of Earth's orbit into the apparent sphere, so when we say "the ecliptic plane" we mean the plane of our orbit.

The point where the ecliptic and the celestial equator intersect is the vernal equinox (Northern Hemisphere seasons). On March 21st this is the apparent position of the Sun in the sky. The line between this point and Earth's center is also the intersection between the equatorial plane and the ecliptic plane.

The geocentric-equatorial reference frame has the origin on Earth's center, the Z axis through the North pole, the X axis pointing to the vernal equinox, and the Y axis follows the right hand rule. Both X and Y will be on the plane of the equator. X will also happen to be on the ecliptic plane, but not Y.

The heliocentric-ecliptic reference frame has the origin on the Sun's center, the X axis pointing to the vernal equinox, the Y axis 90º ahead in the direction of Earth's orbit, and the Z axis pointing North perpendicular to the equatorial plane (it's not coincident with the Sun's North pole).

The perifocal coordinate system makes the XY plane coincident with the satellite's orbit. The X axis points to the periapsis, the Y axis is 90º ahead in the direction of its motion and the Z axis completes the right hand rule.

Source for the 3 above: Fundamentals of Astrodynamics by Bate, Mueller and White; ISBN 0-486-60061-0.

I haven't found a geocentric-ecliptic frame in bibliography, but I have used it and I'm sure it does exist. Basically it's centered on Earth, X axis to the vernal equinox, Z axis pointing North perpendicular to the ecliptic plane and the Y axis completes the right hand rule.

If you use geocentric-ecliptic and heliocentric-ecliptic there's a nice simplification as the XY plane is coincident, so you just have to add angles to convert from one to the other. The perifocal frame doesn't have this property so you need a rotation to convert, but it's nice because you only need one angle to describe your satellite's position.

Are you familiar with Spherical coordinate systems? I assume yes because you have used trigonometry in your code, if not you'll be able to understand it.

So when you use 3d vectors and x,y,z variables you must know what reference frame they refer to. I think that's all you need to do the conversions, though you may need a pen and a paper to draw some arrows and angles before you understand everything.
 
  • #5
martiandawn said:
Are you familiar with Spherical coordinate systems? I assume yes because you have used trigonometry in your code, if not you'll be able to understand it.

actually nope.. the most of the calculations in my code I have done with using equations from: http://www.braeunig.us/space/orbmech.htm - I use Unity3D to show me the graphics, in my test case I placed the sun at xyz 0,0,0 - and the Earth at around 147098291000 meters from it on X axis, so I had something that looked like something I could refer to. and gave Earth and velocity of 30288.01431 m/s on the Z axis, so that it would have an orbit period of 365 days.

After reading your reply, I think I need to study some more in basic trigonometry, I'll just continue to try figure the whole thing out, and some day it should probably work like I want it to :D

Thank you for helping :)
 
  • #6
After reading your reply, I think I need to study some more in basic trigonometry

Don't worry, it's not complicated if you already know what sine and cosine are. It'll take little time to grasp the concept and apply it to your code.
 
  • #7
I made an online calculator that does this: http://orbitsimulator.com/formulas/OrbitalElements.html
It converts between vectors and orbital elements. It's a JavaScript, so you can view the code. The code is pretty much using straight-forward methods found in many celestial mechanic textbooks, and even Wikipedia.
 
  • Like
Likes 1 person
  • #8
Ajes said:
Hello smart people!

I am trying to make a simulation of an orbit with C#. I have come so far that I more or less only need a way to convert the apoapsis, periapsis and ascending node to 3D space vector3's. If it is possible, I want to avoid longitude and latitude?

Anyone have any suggestions?

my code: http://pastebin.com/5mbUVm99 [Broken]
hello , I was asked to develop what you already did, could you please share the code with me since the link you provided is not working, and if you know other way to do it instead of using OpenGL cause i never used it
thanks
 
Last edited by a moderator:
  • #9
Ajes said:
Hello smart people!

I am trying to make a simulation of an orbit with C#. I have come so far that I more or less only need a way to convert the apoapsis, periapsis and ascending node to 3D space vector3's. If it is possible, I want to avoid longitude and latitude?

Anyone have any suggestions?

my code: http://pastebin.com/5mbUVm99 [Broken]

Several books here would probably help you.
http://www.willbell.com/math/index.htm
None of it is terribly difficult to understand, but it takes a while to get your head into that mode of thinking.
 
Last edited by a moderator:

1. How do you calculate orbit figures using C# and 3D space?

To calculate orbit figures, you first need to understand the basic principles of orbital mechanics. This includes understanding concepts such as Kepler's laws of planetary motion and Newton's laws of motion. Once you have a good understanding of these principles, you can use mathematical equations and algorithms to calculate orbit figures using C# and 3D space.

2. What are the necessary components for calculating orbit figures with C# and 3D space?

To calculate orbit figures with C# and 3D space, you will need a programming environment such as Visual Studio and a solid understanding of C# programming language. In addition, you will need to have a good grasp of 3D space concepts and mathematical equations related to orbital mechanics.

3. Can C# be used for all types of orbital calculations?

Yes, C# can be used for various types of orbital calculations such as elliptical, circular, and parabolic orbits. However, the complexity of the calculations may vary depending on the type of orbit and the specific scenario.

4. Are there any helpful resources or libraries for calculating orbit figures in C#?

Yes, there are various libraries and resources available that can help with calculating orbit figures in C# and 3D space. Some popular libraries include Math.NET Numerics and OpenTK. Additionally, there are many online tutorials and forums that can provide guidance and support for this type of calculation.

5. Is it necessary to have a background in physics or aerospace engineering to calculate orbit figures with C# and 3D space?

While having a background in physics or aerospace engineering can be helpful, it is not necessary to calculate orbit figures with C# and 3D space. As long as you have a strong understanding of the underlying principles and mathematical equations, you can successfully calculate orbit figures using C#.

Similar threads

  • Astronomy and Astrophysics
Replies
4
Views
2K
  • Astronomy and Astrophysics
Replies
15
Views
2K
  • Astronomy and Astrophysics
Replies
4
Views
3K
Replies
3
Views
985
  • Astronomy and Astrophysics
Replies
4
Views
12K
  • Astronomy and Astrophysics
Replies
1
Views
1K
Replies
30
Views
3K
  • Astronomy and Astrophysics
Replies
1
Views
1K
  • Astronomy and Astrophysics
Replies
3
Views
3K
  • Astronomy and Astrophysics
Replies
4
Views
3K
Back
Top