[mapguide-internals] 3D CircularArc issues
Maksim Sestic
max at geoinova.com
Tue Sep 20 06:34:45 EDT 2011
Hi Gavin,
Actually, I was in the middle of porting parts of geometry API to .NET when
I run into this issue (among other things, BTW). I'm also aware that both
FDO and MG share "common" geometry API, while certain solutions found there
originate back to AGDS. Few thingies I've noticed alongside:
- There's two methods of getting Arc center, both involving matrices. The
one is found in SpatialUtilityGeometryExtents.cpp, the other in
SpatialUtilityCircularArc.cpp.
MgSpatialUtilityCircularArc::ComputeCenterRadiusAnglesFromThreePositionsAndN
ormal() uses LUDecomposition, which is overkill.
- "Straight" arcs (arcs whose SP/MP/EP are collinear) are considered
invalid. Why is this so? This is simply a special case, just like an arc
forming a circle.
- Certain geometric methods used in code could be improved. I think that
finding 3D arc's length is one of them :-) Will get back with results once I
finish adapting it to .NET
It would be helpful if FDO/MG provided unit tests on this simplified
geometry level, including special cases for ill-conditioning. I'm preparing
a set of my own unit tests, although structure of my code is not applicable
here.
Regards,
Maksim Sestic
-----Original Message-----
From: mapguide-internals-bounces at lists.osgeo.org
[mailto:mapguide-internals-bounces at lists.osgeo.org] On Behalf Of Gavin
Cramer
Sent: Tuesday, September 20, 2011 07:10
To: MapGuide Internals Mail List
Subject: RE: [mapguide-internals] 3D CircularArc issues
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
_______________________________________________
mapguide-internals mailing list
mapguide-internals at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
__________ Information from ESET NOD32 Antivirus, version of virus signature
database 6478 (20110920) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
__________ Information from ESET NOD32 Antivirus, version of virus signature
database 6478 (20110920) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
More information about the mapguide-internals
mailing list