[mapguide-internals] 3D CircularArc issues
Maksim Sestic
max at geoinova.com
Mon Sep 19 07:59:19 EDT 2011
Hi all,
It seems that there's issues with CircularArc implementation, or maybe I'm
having problems understanding source code:
In file SpatialUtilityCircularArc.cpp:
Method void
MgSpatialUtilityCircularArc::ComputeCenterRadiusAnglesFromThreePositionsAndN
ormal() defines Start/End angle theta and phi values as follows:
// Compute start_angle and end_angle
m_startAngle.m_theta = atan2(m_start->GetY() - m_center->GetY(),
m_start->GetX() - m_center->GetX());
if (m_startAngle.m_theta == -MgMathUtility::GetPi())
m_startAngle.m_theta = MgMathUtility::GetPi();
m_startAngle.m_phi = m_hasZ? asin((m_start->GetZ() - m_center->GetZ()) /
m_radius) : 0.0;
m_endAngle.m_theta = atan2(m_end->GetY() - m_center->GetY(),
m_end->GetX() - m_center->GetX());
if (m_endAngle.m_theta == -MgMathUtility::GetPi())
m_endAngle.m_theta = MgMathUtility::GetPi();
m_endAngle.m_phi = m_hasZ? asin((m_end->GetZ() - m_center->GetZ()) /
m_radius) : 0.0;
Please note that Start/End angle phi value is prone to error, e.g. using
following values for stard (SP), mid (MP) and end point (EP) of an 3D
circular arc:
SP = 220932.945, 205589.3036, 60.834
MP = 220957.505, 205585.6127, 60.882
EP = 220962.4382, 205584.7477, -38.525
for this particular part:
asin((m_end->GetZ() - m_center->GetZ())
obviuously fails if difference between EndPoint.Z and CenterPoint.Z exceeds
-1/1 range.
Above errors affect following method: void
MgSpatialUtilityCircularArc::ComputeLengthFromCenterRadiusAnglesAndNormal()
...making 3D arc's length computation impossible (via spherical
trigonometry).
Regards,
Maksim Sestic
More information about the mapguide-internals
mailing list