Julio Jerez wrote:remember g is not the 9.8 it is the general gravitational newton force.
Right - I understand. Here is my "version" of what you wrote, much lengthier but I think it does the same thing
- Code: Select all
NewtonBodyGetMatrix(body, &matrix[0][0]);
NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);
double toOrigin[3] = {matrix.m_posit.m_x, matrix.m_posit.m_y, matrix.m_posit.m_z};
normalize(toOrigin);
double fRadius = sqrt( matrix.m_posit.m_x*matrix.m_posit.m_x + matrix.m_posit.m_y*matrix.m_posit.m_y + matrix.m_posit.m_z*matrix.m_posit.m_z );
dFloat dGravity = (dFloat)(-M_GM / (fRadius*fRadius));
dVector gravityForce (mass * dGravity * toOrigin[0], mass * dGravity * toOrigin[1], mass * dGravity * toOrigin[2], 1.0f);
Julio Jerez wrote:you can chose an earth center frame with the y axis aligned to the line the connect the north and south pole. That may be restrictive because it will limit your simulator to low earth orbit objects.
Right, except, my coordinate frame has a Z-axis from pole to pole, but that's trivial. Unfortunately, I HAVE to chose earth center frame because my visual display engine has an upper ceiling of 100,000,000 ft (30480 km) above ground, almost to an earth geostationary orbit - it will not allow positioning of objects any farther than that. The visual display engine was designed as a flight simulator, so the developer didn't see the need to have user go too far into space. I am OK with that, in fact, I have contacted the developer and they acknowledged that they might consider extending or removing this limit, but they want to see how far I can push this project first. So - Earth Center Frame it is, for now.
Julio Jerez wrote:a more general inertial frame can be the sun a the origin and the up vector the perpendicular to the earth orbit around the sum, but in that model you can simulate the seasons
As far as seasons, they are simulated already, (different land textures and correct sun/star positions) but that is done based on time, not on simulating Earth as an object circling around sun.
For now, I am content with simulating Low to Medium Earth Orbit, with present-day and soon to be space hardware, (and of course, historic, Apollo, Gemini, Vostok). This is NOT a space shooter, but a realistic simulator

I have given thought to simulating other celestial bodies (moon, Mars) by re-sizing and re-texturing the Earth into moon or Mars (I have an ability to do so using the SDK that is the part of the Flight Simulator), and letting user perform a trajectory burn towards, let's say, Mars, quitting Earth-mode, re-configuring for Mars-mode and re-starting in Mars-mode with a calculated incoming velocity trajectory from Earth. It would be like a hibernation, time-compression sleep
Julio Jerez wrote:let us say you use the first coordinate system.
in this system your code that equation in your force and torque callback, the earth static is a static body with a fixed angular velocity that you integrate manually each frame. for now see if you can get model one working and them lots of things will make sense to you that do not seem logical now.
I totally agree. I will implement this shortly!