The difference between Length and ApproximateLength in Curve class

208ramyy98
Explorer
Explorer

The difference between Length and ApproximateLength in Curve class

208ramyy98
Explorer
Explorer

In the Curve class, to get the length of a curve, there is a Length property and an ApproximateLength property? what is the difference between them? 
My first guess would be that Length is more accurate and ApproximateLength is faster, but why would this be the case, I can't find any details in the documentation. 

0 Likes
Reply
345 Views
3 Replies
Replies (3)

jeremy_tammik
Autodesk
Autodesk

I have never seen any detailed description either. I doubt any has been published, and maybe none exists, even internally. For may types of curves, the results will probably be identical. Differences probably only occur for pretty complex curves. To make sure, I asked the development team for you. However, the most efficient and fruitful way to address this question may be to implement a little test suite with benchmarking and try it out for yourself, especially addressing the use cases of interest to you. Please do share your results with us. Thank you!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

mhannonQ65N2
Advocate
Advocate

That is likely correct, calculating the length of some curves is more difficult (and thus likely more time consuming) than it is for other curves. For example, there is no closed-form expression for the arc length of an ellipse.

0 Likes

jeremy_tammik
Autodesk
Autodesk

The development team reply: 

  

Seems pretty well documented in the remarks for the ApproximateLength property to me. ApproximateLength is completely accurate for uniform curves (lines and arcs) but could be off by as much as 2x for non uniform curves, and so it may be worth checking the curve’s class and deciding which method to call from there, or just using the Length property in all cases (what I recommend as the time savings hasn’t shown to be significant in my work) if accuracy is a concern.

 

Specifically, ApproximateLength uses a rough approximation that depends on the curve type. There's no guarantee (of which I am aware) that the approximation method will be unchanged in a future release. Length performs a line integral to compute the curve length, which can be considered exact for all practical purposes (lines and arcs have closed-form expressions for their lengths, which are used instead). I agree that a user is unlikely to see a noticeable performance difference between the two methods. The performance differences are mostly relevant for internal usage (e.g, in graphics functionality).

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes