+ return FGForce::GetBodyForces();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// Build a local "ground" coordinate system defined by
+// eX : normal to the ground
+// eY : projection of the rolling direction on the ground
+// eZ : projection of the sliping direction on the ground
+
+void FGLGear::ComputeGroundCoordSys(void)
+{
+ // Euler angles are built up to create a local frame to describe the forces
+ // applied to the gear by the ground. Here pitch, yaw and roll do not have
+ // any physical meaning. It is just a convenient notation.
+ // First, "pitch" and "yaw" are determined in order to align eX with the
+ // ground normal.
+ if (vGroundNormal(eZ) < -1.0)
+ vOrient(ePitch) = 0.5*M_PI;
+ else if (1.0 < vGroundNormal(eZ))
+ vOrient(ePitch) = -0.5*M_PI;
+ else
+ vOrient(ePitch) = asin(-vGroundNormal(eZ));
+
+ if (fabs(vOrient(ePitch)) == 0.5*M_PI)
+ vOrient(eYaw) = 0.;
+ else
+ vOrient(eYaw) = atan2(vGroundNormal(eY), vGroundNormal(eX));
+
+ vOrient(eRoll) = 0.;
+ UpdateCustomTransformMatrix();
+
+ if (eContactType == ctBOGEY) {
+ // In the case of a bogey, the third angle "roll" is used to align the axis eY and eZ
+ // to the rolling and sliping direction respectively.
+ FGColumnVector3 updatedRollingAxis = Transform().Transposed() * mTGear
+ * FGColumnVector3(-sin(SteerAngle), cos(SteerAngle), 0.);
+
+ vOrient(eRoll) = atan2(updatedRollingAxis(eY), -updatedRollingAxis(eZ));
+ UpdateCustomTransformMatrix();
+ }