Drawing 2D Curves
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
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.
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.
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement