[mapguide-internals] 3D CircularArc issues
Gavin Cramer
gavin.cramer at autodesk.com
Tue Sep 20 01:10:29 EDT 2011
Hello, Maksim. Finally, someone take a look at this! I posed a similar question years ago... which I noticed because I wrote the original FDO code from which this package is copied. I would like to take a look at it again, but I am swamped until at least early October.
What I recall of this is that better precautions against ill-conditioning were taken in ComputeLengthFromCenterRadiusAnglesAndNormal(), but that ComputeCenterRadiusAnglesFromThreePositionsAndNormal was not revisited for the same issue.
For those who do not know what ill-conditioning is, I left comments in ComputeLengthFromCenterRadiusAnglesAndNormal()...
// In the 3D case, use spherical trigonometry. To avoid ill-conditioning
// of the arccosine and arcsine functions, this will be the two-parameter
// arctangent form of the Haversine formula (e.g. rather than the Law of Cosines).
//
// The ill-conditioning of certain angles stretch
// the accuracy of the trig functions. For example, the arcosine
// function breaks down for values near 1.0...
// cos (5 degrees) = 0.996194698
// cos (1 degree) = 0.999847695
// cos (1 minute) = 0.9999999577
// cos (1 second) = 0.9999999999882
// cos (0.05 sec) = 0.999999999999971
// Credits:
// http://www.census.gov/cgi-bin/geo/gisfaq?Q5.1
// http://mathforum.org/library/drmath/view/51879.html
// http://mathforum.org/library/drmath/view/51711.html
// http://mathforum.org/library/drmath/view/54680.html
Maksim, is this the issue of concern for you? Do you have the wherewithal to make a code fix? If so, it should be applied to the original FdoSpatial package as well.
Gavin
-----Original Message-----
From: mapguide-internals-bounces at lists.osgeo.org [mailto:mapguide-internals-bounces at lists.osgeo.org] On Behalf Of Maksim Sestic
Sent: Monday, September 19, 2011 7:59 AM
To: mapguide-internals at lists.osgeo.org
Subject: [mapguide-internals] 3D CircularArc issues
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
_______________________________________________
mapguide-internals mailing list
mapguide-internals at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
More information about the mapguide-internals
mailing list