We have encountered a strange behaviour using ICurve.QueryTangent (on straight lines, not tested with other types). If you supply a value of exactly 0.0 (zero) for the DistanceAlongCurve argument, the resulting tangent is/has an empty geometry. Changing the value to something very close to 0.0 (zero), for example 5.0e-324, QueryTangent works as expected. The wrong behaviour doesn't seem to be dependant on the other values supplied to QueryTangent (extension method, length of the resulting tangent etc.)

This is our workaround which corrects the problem for us, however it's kind of an unpleasent hack. Can someone else confirm this behaviour? Could you coders at Esri look at this too, to see if the QueryTangent method can not handle zero values correctly (and if so, update the documentation accordingly or correct the problem)?

Thank you!

This is our workaround which corrects the problem for us, however it's kind of an unpleasent hack. Can someone else confirm this behaviour? Could you coders at Esri look at this too, to see if the QueryTangent method can not handle zero values correctly (and if so, update the documentation accordingly or correct the problem)?

Thank you!

At this point, pTangent1 has an empty geometry if rDistOnLine was exactly 0.0 before calling QueryTangent. pCurve is defined as ICurve, and given into the method, and so is pPoint, which is an IPoint having valid coordinates (so no var declaration for these). pCurve is actually a geometry coming straight from the database, pPoint is a click/snap-coordinate.

Adding the following code right before QueryTangent makes the whole method working every single time:

The parts of code not supplied consist of handling errors, I skipped it from the example.

What you describe is of course the intended behaviour of the function. Let me explain: QueryPointAndDistance is used to find the distance of pPoint on pCurve. We want to find get the tangent of pCurve at that point. There are cases where pPoint exactly matches the from point, resulting in rDistOnLine being exactly zero (0.0). In that case, QueryTangent fails, unless I change rDistOnLine from exactly zero to 5.0e-324 (which is almost, but not quite exactly zero). Resulting in the very same tangent as I would expect it from calling QueryTangent with 0.0 (exactly zero). However, when calling QueryTangent with DistOnCurve = 0.0, the resulting geometry is empty, which it is not when calling with DistOnCurve = 5.0e-324.

Ok, I'm having a hard time to explain what the method does. Hope I have been able to clarify things a bit? Actually, it doesn't matter which method changes or sets rDistOnLine. Whenever it is exactly zero, QueryTangent generates an emtpy geometry.