Re: Converting various curves into straight line segment approximations.
- From: Kenneth Sloan <KennethRSloan@xxxxxxxxx>
- Date: Fri, 15 Aug 2008 15:34:04 -0500
GetArmy wrote:
Hi,
I'm looking for some help in converting various curves into straight
line segment approximations of those curves.
The backgroud to this is that I am writing an app which displays and
measures objects in CAD files. I can only calculate the lengths and
areas of straight line and not curves!
The types of obejcts that I need to convert are splines and ellipses,
basically any of the autocad 'curvy' drawing types.
I have already written a routine to convert simple arcs into straight
line segments but my maths is not up to the job of converting the more
complex shapes.
Is there a name for this process so that I may look up some more
information?
Do you know of any MS Visual Basic compatible libraries that may
provide this functionality or perhaps there is some example source
code somewhere that will acomplish this function?
I am very grateful for any input you can provide.
Thanks
Mike
This is an ancient problem, with several methods of attack.
Given what you have outlined, above, I recommend three different approaches:
a) Pick a point (preferably one with high curvature - but if you don't know how to do that, it doesn't matter so much). Walk the curve in "small" increments. At each step, ask "is a straight line an adequate representaton of the curve, so far". If so, continue. If not, step BACK at least one step, commit to the straight line TO that point, and start growing another FROM that point. There are lots of minor twiddles to improve this - but this will get you started.
b) divide the entire curve into "small" straight-line segments. Compute a curvature at each vertex (either from the underlying curve, or from your dense polygonal approximation). REMOVE vertices with low curvature. Continue until you reach some threshold on the "goodness" of your current approximation.
c) construct a polygon with a small number of sides (but where each side is very big). For example, start with a triangle, with vertices place approximately at 0, 0.33, 0.66 along the curve (precision does not matter here). Look at each straight line piece of this polygon and find the point on the curve that is FURTHEST from the straight line. Insert that point as a new vertex in your polygon. Continue until the furthest point is close enough for gov't. work.
In all of these methods, there are sub-parts that can be solved either continuosly or by using a very dense discrete approximation. Select the method that matches your skills.
Look in the Computer Vision literature for methods. This was a moderately active topic in the late 70's and 80's.
--
Kenneth Sloan KennethRSloan@xxxxxxxxx
Computer and Information Sciences +1-205-932-2213
University of Alabama at Birmingham FAX +1-205-934-5473
Birmingham, AL 35294-1170 http://KennethRSloan.com/
.
- References:
- Prev by Date: Re: Bilinear interpolation -- finding original coefficients
- Next by Date: hpgl project
- Previous by thread: Re: Converting various curves into straight line segment approximations.
- Next by thread: hpgl project
- Index(es):
Relevant Pages
|
Loading