Archived

This topic is now archived and is closed to further replies.

Drawing 2D Curves

This topic is 5622 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I''d like to know how to draw curves quickly (2D). My curves are represented by a list of (generally small) segments. I''d like to avoid drawing some of the segments for speed purposes (When I draw thick lines for the segments, some segments are wholly overdrawn). I guess there''re also algebric ways of approximating the shape of such curves and I''d like to hear about it. Thanks, Oren Becker. http://qsoft.ragestorm.com

Share this post


Link to post
Share on other sites
search for subdivision or adaptive subdivision.

The basic approach is something like this (although there are many flavors of this)... Approximate the curve with a very small number of line segments. For each segment, compare the distance between the line segment midpoint and the equivalent point of the curve with some tolerance value. If it is greater, split the segment with a new point at the real point on the curve and repeat until everything is within some tolerance.

I won''t attempt ascii art, but this shoulde be pretty simple...
Imagine you are drawing the graph of x^2 between -2 and 2. Start with a line between (-2, 4) and (2, 4). Find the distance between the middle of that line segment (0, 4) and the middle of the curve (0, 0). Assuming it''s too large, split the line into two segments between the points (-2, 4), (0, 0), (2, 4). Now, you have a V shape, Repeat this process until all segments match within some tolerance or you get extremely bored.

Share this post


Link to post
Share on other sites