|
|
|
@ -1,62 +1,5 @@ |
|
|
|
#include "objectSystemAnchor.h"
|
|
|
|
|
|
|
|
position3D::position3D(){ |
|
|
|
x = y = z = lat = lon = rot_z = rot_y = rot_z = speed = 0.f; |
|
|
|
utmZone = 0; |
|
|
|
}; |
|
|
|
|
|
|
|
position3D::~position3D(){ |
|
|
|
}; |
|
|
|
|
|
|
|
void position3D::setPositionWGS84( C3D_FLOAT Lat, C3D_FLOAT Lon, C3D_FLOAT Alt ){ |
|
|
|
coordConverter CC; |
|
|
|
lat = Lat; |
|
|
|
lon = Lon; |
|
|
|
z = Alt; |
|
|
|
#ifdef FLOAT_64
|
|
|
|
double A, B; |
|
|
|
CC.LatLonToUTMXY( lat, lon, utmZone, A, B ); |
|
|
|
x = A; |
|
|
|
y = B; |
|
|
|
#else
|
|
|
|
CC.LatLonToUTMXY( lat, lon, utmZone, x, y ); |
|
|
|
#endif
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
void position3D::setPositionXYZ( C3D_FLOAT X, C3D_FLOAT Y, C3D_FLOAT Z, int zone ){ |
|
|
|
coordConverter CC; |
|
|
|
if( zone != 0 ) utmZone = zone; |
|
|
|
x = X; |
|
|
|
y = Y; |
|
|
|
z = Z; |
|
|
|
#ifdef FLOAT_64
|
|
|
|
double A, B; |
|
|
|
CC.UTMXYToLatLon(x, y, utmZone, false, A, B); |
|
|
|
lat = A; |
|
|
|
lon = B; |
|
|
|
#else
|
|
|
|
CC.UTMXYToLatLon(x, y, utmZone, false, lat, lon); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
|
|
|
|
void position3D::setOrientationRad( C3D_FLOAT RotX, C3D_FLOAT RotY, C3D_FLOAT RotZ ){ |
|
|
|
rot_x = RotX; |
|
|
|
rot_y = RotY; |
|
|
|
rot_z = RotZ; |
|
|
|
}; |
|
|
|
|
|
|
|
void position3D::setOrientationDeg(C3D_FLOAT RotX, C3D_FLOAT RotY, C3D_FLOAT RotZ){ |
|
|
|
rot_x = deg2rad(RotX); |
|
|
|
rot_y = deg2rad(RotY); |
|
|
|
rot_z = deg2rad(RotZ); |
|
|
|
}; |
|
|
|
|
|
|
|
void position3D::setSpeed( C3D_FLOAT Speed ){ |
|
|
|
speed = Speed; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
systemAnchor* systemAnchor::_instance = 0; |
|
|
|
|
|
|
|
/**
|
|
|
|
@ -72,9 +15,10 @@ systemAnchor* systemAnchor::getInstance() { |
|
|
|
return _instance; |
|
|
|
}; |
|
|
|
|
|
|
|
systemAnchor::systemAnchor(){ |
|
|
|
systemAnchor::systemAnchor(): m_SCC(){ |
|
|
|
config_setting_t *pSetting; |
|
|
|
m_pSettings = NULL; |
|
|
|
m_bSouthHemisphere = 0; |
|
|
|
pSetting = basicSettingsProvider::getInstance()->getSubNode( NULL, "APPLICATION_GUI" ); |
|
|
|
if( pSetting != NULL ){ |
|
|
|
m_pSettings = basicSettingsProvider::getInstance()->getSubNode( pSetting, "SYSTEM_ANCHOR" ); |
|
|
|
@ -108,43 +52,22 @@ systemAnchor::systemAnchor(){ |
|
|
|
} else { |
|
|
|
z = config_setting_get_float(pSetting); |
|
|
|
}; |
|
|
|
/* No need to set Anchore Orientation
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ROLL ); |
|
|
|
if (pSetting == NULL){ |
|
|
|
rot_y = 0.f; |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_ROLL, CONFIG_TYPE_FLOAT ); |
|
|
|
config_setting_set_float(pSetting, rot_y); |
|
|
|
basicSettingsProvider::getInstance()->compromise(); |
|
|
|
} else { |
|
|
|
rot_y = config_setting_get_float(pSetting); |
|
|
|
}; |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_PITCH ); |
|
|
|
if (pSetting == NULL){ |
|
|
|
rot_x = 0.f; |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_PITCH, CONFIG_TYPE_FLOAT ); |
|
|
|
config_setting_set_float(pSetting, rot_x); |
|
|
|
basicSettingsProvider::getInstance()->compromise(); |
|
|
|
} else { |
|
|
|
rot_x = config_setting_get_float(pSetting); |
|
|
|
}; |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_YAW ); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_SOUTH_HS); |
|
|
|
if (pSetting == NULL){ |
|
|
|
rot_z = 0.f; |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_YAW, CONFIG_TYPE_FLOAT ); |
|
|
|
config_setting_set_float(pSetting, rot_z); |
|
|
|
m_bSouthHemisphere = false; |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_SOUTH_HS, CONFIG_TYPE_BOOL ); |
|
|
|
config_setting_set_bool(pSetting, m_bSouthHemisphere); |
|
|
|
basicSettingsProvider::getInstance()->compromise(); |
|
|
|
} else { |
|
|
|
rot_z = config_setting_get_float(pSetting); |
|
|
|
m_bSouthHemisphere = config_setting_get_bool(pSetting); |
|
|
|
}; |
|
|
|
*/ |
|
|
|
coordConverter CC; |
|
|
|
#ifdef FLOAT_64
|
|
|
|
double A, B; |
|
|
|
utmZone = CC.LatLonToUTMXY( lat, lon, 0 , A, B ); |
|
|
|
x = A; |
|
|
|
y = B; |
|
|
|
#else
|
|
|
|
utmZone = CC.LatLonToUTMXY(lat, lon, 0, x, y); |
|
|
|
utmZone = m_SCC.LatLonToUTMXY(lat, lon, m_bSouthHemisphere, x, y); |
|
|
|
#endif
|
|
|
|
basicSettingsProvider::getInstance()->validate(); |
|
|
|
}; |
|
|
|
@ -153,6 +76,7 @@ systemAnchor::systemAnchor(){ |
|
|
|
systemAnchor::~systemAnchor(){ |
|
|
|
config_setting_t *pSetting; |
|
|
|
C3D_FLOAT tVal; |
|
|
|
bool tBool; |
|
|
|
|
|
|
|
m_pSettings = NULL; |
|
|
|
pSetting = basicSettingsProvider::getInstance()->getSubNode( NULL, "APPLICATION_GUI" ); |
|
|
|
@ -197,45 +121,177 @@ systemAnchor::~systemAnchor(){ |
|
|
|
basicSettingsProvider::getInstance()->compromise(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
/*
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ROLL); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_SOUTH_HS); |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_ROLL, CONFIG_TYPE_FLOAT ); |
|
|
|
config_setting_set_float(pSetting, rot_y ); |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_SOUTH_HS, CONFIG_TYPE_BOOL ); |
|
|
|
config_setting_set_bool(pSetting, m_bSouthHemisphere ); |
|
|
|
basicSettingsProvider::getInstance()->compromise(); |
|
|
|
} else { |
|
|
|
tVal = config_setting_get_float(pSetting); |
|
|
|
if (rot_y != tVal){ |
|
|
|
config_setting_set_float(pSetting, rot_y); |
|
|
|
tBool = config_setting_get_bool(pSetting); |
|
|
|
if (m_bSouthHemisphere != tBool){ |
|
|
|
config_setting_set_bool(pSetting, m_bSouthHemisphere ); |
|
|
|
basicSettingsProvider::getInstance()->compromise(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_PITCH); |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_PITCH, CONFIG_TYPE_FLOAT ); |
|
|
|
config_setting_set_float(pSetting, rot_x); |
|
|
|
basicSettingsProvider::getInstance()->compromise(); |
|
|
|
} else { |
|
|
|
tVal = config_setting_get_float(pSetting); |
|
|
|
if (rot_x != tVal){ |
|
|
|
config_setting_set_float(pSetting, rot_x); |
|
|
|
basicSettingsProvider::getInstance()->compromise(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_YAW); |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_YAW, CONFIG_TYPE_FLOAT ); |
|
|
|
config_setting_set_float(pSetting, rot_z); |
|
|
|
basicSettingsProvider::getInstance()->compromise(); |
|
|
|
} else { |
|
|
|
tVal = config_setting_get_float(pSetting); |
|
|
|
if (rot_z != tVal){ |
|
|
|
config_setting_set_float(pSetting, rot_z); |
|
|
|
basicSettingsProvider::getInstance()->compromise(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
*/ |
|
|
|
basicSettingsProvider::getInstance()->validate(); |
|
|
|
}; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
bool systemAnchor::convertToLocal(basicPosition *SP, C3D_WGS84_LOC POS, C3D_SPH_DEGREES& LOC) { |
|
|
|
if (SP == NULL) return false; |
|
|
|
transform_3* pTF = SP->getTransform(); |
|
|
|
C3D_DECART tDec; |
|
|
|
vector_3 A, B; |
|
|
|
tDec.z = POS.alt; |
|
|
|
m_SCC.LatLonToUTMXY(POS.lat, POS.lon, SP->getUTMZone(), tDec.x, tDec.y); |
|
|
|
A[0] = tDec.x - SP->getX(); |
|
|
|
A[1] = tDec.y - SP->getY(); |
|
|
|
A[2] = tDec.z - SP->getZ(); |
|
|
|
pTF->get_vector_local(A, B); |
|
|
|
tDec.x = B[0]; |
|
|
|
tDec.y = B[1]; |
|
|
|
tDec.z = B[2]; |
|
|
|
decart2spherical(tDec, LOC); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool systemAnchor::convertToLocal(basicPosition *SP, C3D_WGS84_LOC POS, C3D_SPH_RADIANS& LOC) { |
|
|
|
if (SP == NULL) return false; |
|
|
|
transform_3* pTF = SP->getTransform(); |
|
|
|
C3D_DECART tDec; |
|
|
|
vector_3 A, B; |
|
|
|
tDec.z = POS.alt; |
|
|
|
m_SCC.LatLonToUTMXY(POS.lat, POS.lon, SP->getUTMZone(), tDec.x, tDec.y); |
|
|
|
A[0] = tDec.x - SP->getX(); |
|
|
|
A[1] = tDec.y - SP->getY(); |
|
|
|
A[2] = tDec.z - SP->getZ(); |
|
|
|
pTF->get_vector_local(A, B); |
|
|
|
tDec.x = B[0]; |
|
|
|
tDec.y = B[1]; |
|
|
|
tDec.z = B[2]; |
|
|
|
decart2spherical(tDec, LOC); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool systemAnchor::convertToLocal(basicPosition *SP, C3D_DECART POS, C3D_SPH_DEGREES& LOC) { |
|
|
|
if (SP == NULL) return false; |
|
|
|
transform_3* pTF = SP->getTransform(); |
|
|
|
C3D_DECART tDec; |
|
|
|
vector_3 A, B; |
|
|
|
// POS - is Relative to System Anchore!!
|
|
|
|
A[0] = getX() + POS.x - SP->getX(); |
|
|
|
A[1] = getY() + POS.y - SP->getY(); |
|
|
|
A[2] = getZ() + POS.z - SP->getZ(); |
|
|
|
pTF->get_vector_local(A, B); |
|
|
|
tDec.x = B[0]; |
|
|
|
tDec.y = B[1]; |
|
|
|
tDec.z = B[2]; |
|
|
|
decart2spherical(tDec, LOC); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool systemAnchor::convertToLocal(basicPosition *SP, C3D_DECART POS, C3D_SPH_RADIANS& LOC) { |
|
|
|
if (SP == NULL) return false; |
|
|
|
transform_3* pTF = SP->getTransform(); |
|
|
|
C3D_DECART tDec; |
|
|
|
vector_3 A, B; |
|
|
|
// POS - is Relative to System Anchore!!
|
|
|
|
A[0] = getX() + POS.x - SP->getX(); |
|
|
|
A[1] = getY() + POS.y - SP->getY(); |
|
|
|
A[2] = getZ() + POS.z - SP->getZ(); |
|
|
|
pTF->get_vector_local(A, B); |
|
|
|
tDec.x = B[0]; |
|
|
|
tDec.y = B[1]; |
|
|
|
tDec.z = B[2]; |
|
|
|
decart2spherical(tDec, LOC); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool systemAnchor::convertToSystem(basicPosition *SP, C3D_WGS84_LOC POS, C3D_DECART& LOC) { |
|
|
|
C3D_DECART tDec; |
|
|
|
tDec.z = POS.alt; |
|
|
|
m_SCC.LatLonToUTMXY(POS.lat, POS.lon, this->getUTMZone(), tDec.x, tDec.y); |
|
|
|
LOC.x = tDec.x - getX(); |
|
|
|
LOC.y = tDec.y - getX(); |
|
|
|
LOC.z = tDec.z - getZ(); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool systemAnchor::convertToSystem(basicPosition *SP, C3D_SPH_DEGREES POS, C3D_DECART& LOC) { |
|
|
|
if (SP == NULL) return false; |
|
|
|
transform_3* pTF = SP->getTransform(); |
|
|
|
C3D_DECART tDec; |
|
|
|
vector_3 A, B; |
|
|
|
spherical2decart(POS, tDec); |
|
|
|
A[0] = tDec.x; |
|
|
|
A[1] = tDec.y; |
|
|
|
A[2] = tDec.z; |
|
|
|
pTF->get_vector_world(A, B); |
|
|
|
LOC.x = SP->getX() + B[0] - getX(); |
|
|
|
LOC.y = SP->getY() + B[1] - getY(); |
|
|
|
LOC.z = SP->getZ() + B[2] - getZ(); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool systemAnchor::convertToSystem(basicPosition *SP, C3D_SPH_RADIANS POS, C3D_DECART& LOC) { |
|
|
|
if (SP == NULL) return false; |
|
|
|
transform_3* pTF = SP->getTransform(); |
|
|
|
C3D_DECART tDec; |
|
|
|
vector_3 A, B; |
|
|
|
spherical2decart(POS, tDec); |
|
|
|
A[0] = tDec.x; |
|
|
|
A[1] = tDec.y; |
|
|
|
A[2] = tDec.z; |
|
|
|
pTF->get_vector_world(A, B); |
|
|
|
LOC.x = SP->getX() + B[0] - getX(); |
|
|
|
LOC.y = SP->getY() + B[1] - getY(); |
|
|
|
LOC.z = SP->getZ() + B[2] - getZ(); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool systemAnchor::convertToGlobal(basicPosition *SP, C3D_SPH_DEGREES POS, C3D_WGS84_LOC& LOC) { |
|
|
|
if (SP == NULL) return false; |
|
|
|
transform_3* pTF = SP->getTransform(); |
|
|
|
C3D_DECART tDec; |
|
|
|
vector_3 A, B; |
|
|
|
spherical2decart(POS, tDec); |
|
|
|
A[0] = tDec.x; |
|
|
|
A[1] = tDec.y; |
|
|
|
A[2] = tDec.z; |
|
|
|
pTF->get_vector_world(A, B); |
|
|
|
tDec.x = B[0] + SP->getX(); |
|
|
|
tDec.y = B[1] + SP->getY(); |
|
|
|
tDec.z = B[2] + SP->getZ(); |
|
|
|
m_SCC.UTMXYToLatLon(tDec.x, tDec.y, getUTMZone(), m_bSouthHemisphere, LOC.lat, LOC.lon); |
|
|
|
LOC.alt = tDec.z; |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool systemAnchor::convertToGlobal(basicPosition *SP, C3D_SPH_RADIANS POS, C3D_WGS84_LOC& LOC) { |
|
|
|
if (SP == NULL) return false; |
|
|
|
transform_3* pTF = SP->getTransform(); |
|
|
|
C3D_DECART tDec; |
|
|
|
vector_3 A, B; |
|
|
|
spherical2decart(POS, tDec); |
|
|
|
A[0] = tDec.x; |
|
|
|
A[1] = tDec.y; |
|
|
|
A[2] = tDec.z; |
|
|
|
pTF->get_vector_world(A, B); |
|
|
|
tDec.x = B[0] + SP->getX(); |
|
|
|
tDec.y = B[1] + SP->getY(); |
|
|
|
tDec.z = B[2] + SP->getZ(); |
|
|
|
m_SCC.UTMXYToLatLon(tDec.x, tDec.y, getUTMZone(), m_bSouthHemisphere, LOC.lat, LOC.lon); |
|
|
|
LOC.alt = tDec.z; |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool systemAnchor::convertToGlobal(basicPosition *SP, C3D_DECART POS, C3D_WGS84_LOC& LOC) { |
|
|
|
C3D_DECART tDec; |
|
|
|
tDec.x = POS.x + getX(); |
|
|
|
tDec.y = POS.y + getY(); |
|
|
|
tDec.z = POS.z + getZ(); |
|
|
|
m_SCC.UTMXYToLatLon(tDec.x, tDec.y, getUTMZone(), m_bSouthHemisphere, LOC.lat, LOC.lon); |
|
|
|
LOC.alt = tDec.z; |
|
|
|
return true; |
|
|
|
}; |