I need to represent circles/arcs in a DXF file using Polylines so to
take advantage of the line weight attribute.
Does anyone know a good way to map circular information (center, radius,
start point, end point, etc.) into a DXF Polyline definition?
Thanks for any input.
Al - a...@ais.org
If you have the start and end point, all you need is the Bulge.
Compute the angle subtended by the arc. Simple-minded: use atan2() to
compute the angle of elevation of the line from the center to the start
point; ditto end point; take end_angle - start_angle; add 2*pi if it's
negative.
Compute tan(that / 4.0); make the sign positive if the arc was
counter-clockwise and negative if clockwise.
Output a DXF polyline header, with the default-width fields set to
whatever width you chose; then a Vertex giving the first point and the
bulge you computed; then a Vertex with the second point; then a SEQEND.
No width information is required in anything but the header.
You can reduce your calls on transcendental functions by computing the
bulge from
tan(acos(V1 . V2) / 4)
where V1 and V2 are the vectors from center to start-point and
end-point, and . is the dot product. However, you need to be very
careful about major and minor arcs, clockwise and counter-clockwise.
Unfortunately, Bulge notation goes infinite for circles, so a Polyline
can't have a single full-circle segment. Use 2 vertices at the ends of
a diameter; set the Closed bit in the header; give each vertex a bulge
of 1.
Hope this helps.
--
Dan Drake
dr...@Autodesk.com