Mathias Frhlich:
This patch makes use of the vectors now available in simgear with that past patch. And using that it simplyfies the carrier code somehow. - Small additional factory's to the quaternion code are done in the simgear part. Also more explicit unit names in the factory functions. - The flightgear part makes use of them and simplyfies some computations especially in the carrier code. - The data part fixes the coordinate frames I used for the park positions in the carrier to match the usual ones. I believed that I had done so, but it was definitly different. Also there are more parking positions avaliable now.
This commit is contained in:
@@ -126,7 +126,7 @@ QuatTest(void)
|
||||
q2 = SGQuat<T>::fromAngleAxis(y, e2);
|
||||
q3 = SGQuat<T>::fromAngleAxis(x, e1);
|
||||
v2 = q3.transform(q2.transform(q1.transform(v1)));
|
||||
q4 = SGQuat<T>::fromEuler(z, y, x);
|
||||
q4 = SGQuat<T>::fromEulerRad(z, y, x);
|
||||
if (!equivalent(q4.transform(v1), v2))
|
||||
return false;
|
||||
|
||||
@@ -219,7 +219,7 @@ sgInterfaceTest(void)
|
||||
{
|
||||
SGVec3f v3f = SGVec3f::e2();
|
||||
SGVec4f v4f = SGVec4f::e2();
|
||||
SGQuatf qf = SGQuatf::fromEuler(1.2, 1.3, -0.4);
|
||||
SGQuatf qf = SGQuatf::fromEulerRad(1.2, 1.3, -0.4);
|
||||
SGMatrixf mf(qf, v3f);
|
||||
|
||||
// Copy to and from plibs types check if result is equal,
|
||||
@@ -266,7 +266,7 @@ sgdInterfaceTest(void)
|
||||
{
|
||||
SGVec3d v3d = SGVec3d::e2();
|
||||
SGVec4d v4d = SGVec4d::e2();
|
||||
SGQuatd qd = SGQuatd::fromEuler(1.2, 1.3, -0.4);
|
||||
SGQuatd qd = SGQuatd::fromEulerRad(1.2, 1.3, -0.4);
|
||||
SGMatrixd md(qd, v3d);
|
||||
|
||||
// Copy to and from plibs types check if result is equal,
|
||||
|
||||
@@ -29,6 +29,11 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static T rad2deg(const T& val)
|
||||
{ return val*180/pi(); }
|
||||
static T deg2rad(const T& val)
|
||||
{ return val*pi()/180; }
|
||||
|
||||
#ifndef NDEBUG
|
||||
/// Returns true if v is a NaN value
|
||||
/// Use with care: allways code that you do not need to use that!
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
{ return fromRealImag(1, SGVec3<T>(0)); }
|
||||
|
||||
/// Return a quaternion from euler angles
|
||||
static SGQuat fromEuler(T z, T y, T x)
|
||||
static SGQuat fromEulerRad(T z, T y, T x)
|
||||
{
|
||||
SGQuat q;
|
||||
T zd2 = T(0.5)*z; T yd2 = T(0.5)*y; T xd2 = T(0.5)*x;
|
||||
@@ -47,17 +47,32 @@ public:
|
||||
return q;
|
||||
}
|
||||
|
||||
/// Return a quaternion from euler angles in degrees
|
||||
static SGQuat fromEulerDeg(T z, T y, T x)
|
||||
{
|
||||
return fromEulerRad(SGMisc<T>::deg2rad(z), SGMisc<T>::deg2rad(y),
|
||||
SGMisc<T>::deg2rad(x));
|
||||
}
|
||||
|
||||
/// Return a quaternion from euler angles
|
||||
static SGQuat fromYawPitchRoll(T y, T p, T r)
|
||||
{ return fromEuler(y, p, r); }
|
||||
{ return fromEulerRad(y, p, r); }
|
||||
|
||||
/// Return a quaternion from euler angles
|
||||
static SGQuat fromYawPitchRollDeg(T y, T p, T r)
|
||||
{ return fromEulerDeg(y, p, r); }
|
||||
|
||||
/// Return a quaternion from euler angles
|
||||
static SGQuat fromHeadAttBank(T h, T a, T b)
|
||||
{ return fromEuler(h, a, b); }
|
||||
{ return fromEulerRad(h, a, b); }
|
||||
|
||||
/// Return a quaternion from euler angles
|
||||
static SGQuat fromHeadAttBankDeg(T h, T a, T b)
|
||||
{ return fromEulerDeg(h, a, b); }
|
||||
|
||||
/// Return a quaternion rotation the the horizontal local frame from given
|
||||
/// longitude and latitude
|
||||
static SGQuat fromLonLat(T lon, T lat)
|
||||
static SGQuat fromLonLatRad(T lon, T lat)
|
||||
{
|
||||
SGQuat q;
|
||||
T zd2 = T(0.5)*lon;
|
||||
@@ -73,6 +88,11 @@ public:
|
||||
return q;
|
||||
}
|
||||
|
||||
/// Return a quaternion rotation the the horizontal local frame from given
|
||||
/// longitude and latitude
|
||||
static SGQuat fromLonLatDeg(T lon, T lat)
|
||||
{ return fromLonLatRad(SGMisc<T>::deg2rad(lon), SGMisc<T>::deg2rad(lat)); }
|
||||
|
||||
/// Create a quaternion from the angle axis representation
|
||||
static SGQuat fromAngleAxis(T angle, const SGVec3<T>& axis)
|
||||
{
|
||||
@@ -80,6 +100,10 @@ public:
|
||||
return fromRealImag(cos(angle2), T(sin(angle2))*axis);
|
||||
}
|
||||
|
||||
/// Create a quaternion from the angle axis representation
|
||||
static SGQuat fromAngleAxisDeg(T angle, const SGVec3<T>& axis)
|
||||
{ return fromAngleAxis(SGMisc<T>::deg2rad(angle), axis); }
|
||||
|
||||
/// Create a quaternion from the angle axis representation where the angle
|
||||
/// is stored in the axis' length
|
||||
static SGQuat fromAngleAxis(const SGVec3<T>& axis)
|
||||
@@ -147,9 +171,9 @@ public:
|
||||
void getEulerDeg(T& zDeg, T& yDeg, T& xDeg) const
|
||||
{
|
||||
getEulerRad(zDeg, yDeg, xDeg);
|
||||
zDeg *= 180/SGMisc<value_type>::pi();
|
||||
yDeg *= 180/SGMisc<value_type>::pi();
|
||||
xDeg *= 180/SGMisc<value_type>::pi();
|
||||
zDeg = SGMisc<T>::rad2deg(zDeg);
|
||||
yDeg = SGMisc<T>::rad2deg(yDeg);
|
||||
xDeg = SGMisc<T>::rad2deg(xDeg);
|
||||
}
|
||||
|
||||
/// write the angle axis representation into the references
|
||||
@@ -186,6 +210,13 @@ public:
|
||||
T& operator()(unsigned i)
|
||||
{ return _data[i]; }
|
||||
|
||||
/// Access raw data by index, the index is unchecked
|
||||
const T& operator[](unsigned i) const
|
||||
{ return _data[i]; }
|
||||
/// Access raw data by index, the index is unchecked
|
||||
T& operator[](unsigned i)
|
||||
{ return _data[i]; }
|
||||
|
||||
/// Access the x component
|
||||
const T& x(void) const
|
||||
{ return _data[0]; }
|
||||
|
||||
@@ -42,6 +42,13 @@ public:
|
||||
T& operator()(unsigned i)
|
||||
{ return _data[i]; }
|
||||
|
||||
/// Access raw data by index, the index is unchecked
|
||||
const T& operator[](unsigned i) const
|
||||
{ return _data[i]; }
|
||||
/// Access raw data by index, the index is unchecked
|
||||
T& operator[](unsigned i)
|
||||
{ return _data[i]; }
|
||||
|
||||
/// Access the x component
|
||||
const T& x(void) const
|
||||
{ return _data[0]; }
|
||||
|
||||
@@ -35,6 +35,13 @@ public:
|
||||
T& operator()(unsigned i)
|
||||
{ return _data[i]; }
|
||||
|
||||
/// Access raw data by index, the index is unchecked
|
||||
const T& operator[](unsigned i) const
|
||||
{ return _data[i]; }
|
||||
/// Access raw data by index, the index is unchecked
|
||||
T& operator[](unsigned i)
|
||||
{ return _data[i]; }
|
||||
|
||||
/// Access the x component
|
||||
const T& x(void) const
|
||||
{ return _data[0]; }
|
||||
|
||||
Reference in New Issue
Block a user