Files
cadcraft/crates/engine
2ez4gcxandClaude Opus 5.5 35b4332ee2 MEASURE picks its starting end by the curve's parameter, as AutoCAD does (#2207)
* MEASURE picks its starting end by the curve's parameter, as AutoCAD does

MEASURE started from whichever end was nearer the pick in a straight
line, and a closed curve always ran forwards from its first vertex.
AutoCAD (2024, black-box: synthetic objects in accoreconsole, every
POINT read back with entget) decides by the curve parameter of the pick,
the segment index plus the fraction along it:

- an open curve is measured from its end once the pick is halfway or
  further: an L-shaped polyline picked at (10, 30) on its long leg
  (parameter 1.3 of 2) runs from the end, although that end is the
  farther one; a U-shape picked at (90, 0) (parameter 0.9 of 3) runs from
  the start, although the end is nearer;
- a closed polyline runs from its first vertex, forwards before half its
  parameter and backwards from then on;
- a circle always runs counterclockwise from angle 0.

Chain::param_of gives that parameter. The new test
divide_and_measure_match_autocad pins nine measured DIVIDE and MEASURE
cases (lines, arcs, circles, open and closed polylines with an arc
segment), every point to 1e-9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* MEASURE: a spline's starting end comes from its own parameter

A spline's chain is a tessellation with zero-length pieces dropped, so
its segment count is not the spline's parameter range: a degree-1 spline
whose first span has zero length spends half its parameter there, and a
pick at x = 3 on its 10-unit run (parameter 1.3 of 0..2, past the middle)
was measured from the start because it is short of the drawn middle.
Splines now compare spline_param_of with the middle of their domain;
other curves keep Chain::param_of. Pointed out in review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* MEASURE: polylines count coincident vertices in their parameter; ellipses pinned

AutoCAD's polyline parameter is the vertex index, so a coincident vertex
still takes one unit of the range. The chain drops zero-length spans, so
its segment index and count shifted the middle: (0,0) (1,0) (101,0)
(101,0) picked at x = 1.1 (parameter 1.001 of 3) was measured from the
end, and (0,0) (0,0) (10,0) (20,0) picked at x = 7 (1.7 of 3) from the
start. LWPOLYLINEs and 3D polylines now take the parameter from their
source vertices (curves::vertex_param_of). Pointed out in review.

Ellipses keep the parameter rule, which AutoCAD follows for them too:
a full ellipse picked at t = pi and an elliptical arc picked past its
middle both run from the end in AutoCAD 2024 (MEASURE-032 and -033 of the
measured set; the other direction is 200 and 4 units off). The new test
pins both, within the 1e-4 tessellation CADCraft measures along.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 21:21:24 -04:00
..