Reading the acceleration

V8Li

Member
Joined
Apr 9, 2008
Messages
200
Reaction score
0
Points
16
I want to get the value of the ACC from SurfaceMFD. Is there a way to get it from what the API offers (vectors) and if so what's the formula?
 
Code:
// calculating ship's initialAcceleration. Thanks to Agentgonzo for the code
        double Thrust = 0;
        const int numThrusters = vessel->GetGroupThrusterCount(THGROUP_MAIN);
        for(int i = 0; i < numThrusters; i++)
        {
            THRUSTER_HANDLE thruster = vessel->GetGroupThruster(THGROUP_MAIN,i);
            Thrust += vessel->GetThrusterMax0(thruster);
        }
        initialAccel = Thrust / vessel->GetMass();
 
This won't return the same value displayed on ACC on the surface MFD. ACC only shows horizontal acceleration. Enjo's forumla will show acceleration provided by the thrusters, but doesn't account for deceleration from drag, and does not show strictly the horizontal acceleration. I don't know a forumula to calculate acceleration in a single time step. In the past I have done this by saving the current horizontal velocity in a variable, and on the next tick, evaluate the Diff Time between ticks, and the change in velocity to derive the acceleration. This isn't the best way to do it I'm sure...
 
Yes, I want the absolute acceleration (and deceleration). I thought there's a way to avoid what reverend suggested but my guess is that Dr. Martin used the same formula since the ACC (SurfaceMFD) seems to be refreshed in steps of about 1 sec despite the MFD refresh rate. I've used the GetForceVector function but I can't come up with a proper formula. I wish the MFDs would have been included in the SDK too.
I'll keep searching...
 
What do you mean by "absolute" acceleration? Acceleration relative to freefall? Acceleration relative to the center of the reference body? Relative to the surface of the reference body? You can be stationary relative to the Earth's surface and be accelerating relative to its center, after all.
 
I want to get the acceleration (and, obviously deceleration) regarding the airspeed; the ACC value from SurfaceMFD. I've used the GetForceVector function and calculated the component vector but I don't think it works since the values returned are not even close:
Code:
void MFDTemplate::HUDacceleration()
{
    VECTOR3 F;
    v->GetForceVector(F);
    sprintf_s(buffer, "%.2f %s", (F.x+(F.y-9.8)+F.z), "m/s^2 rn");
    strcat_s(HUD_lines, _countof(buffer), buffer);
}
This is the component: (F.x+(F.y-9.8)+F.z).
I've got the Accelerometer too but doesn't help much since it is just interpreting the individual force vectors.

Any ideas (that involve the Orbiter API)?
 
First, 9.8 is acceleration, not force. Second, make sure that x,y,z are not in global frame. I'd say that you need local frame, but I'm not so sure. Section 11.11, page 89. You have some examples of the Global to Local, etc transformations in Orbital Scenery sources here: [ame="http://www.orbithangar.com/searchid.php?ID=3338"]Orbital Scenery v. 0.1[/ame]
 
It was a bad approach, maybe fueled by the fact that I've calculated the g force using the vectors (Enjo, I was decreasing the 9.80665 from the y vector to null the gravitational force).
Here's the final version, maybe it will help someone:

Code:
double curAirSpeed;
simTime = oapiGetSimTime();
curAirSpeed = v->GetAirspeed();
acc = (curAirSpeed - tmp_airspeed)/(simTime - lastSimTime);
lastSimTime = simTime;
tmp_airspeed = curAirSpeed;
double simTime, lastSimTime, tmp_airspeed, acc are class variables.
 
Ephinany

You do realize, don't you, you can't be truly stationary, if you get out of Earth's gravity, your now in a solar orbit, if you get out of that, your orbiting the center of the Milky Way, if you get out of that, then your still moving, because of the expansion of the universe includes you.
 
Back
Top