Overview
/
KCL Standard Library
/
Functions
/
solver::distance

solver::distanceFunction in std::solver

Constrain the distance between two sketch entities.

The distance is always non-negative, and the order of the two entities does not matter: distance([a, b]) == 5mm and distance([b, a]) == 5mm are the same constraint. This differs from horizontalDistance and verticalDistance, which are signed and order-sensitive.

Supported entity pairs (in either order):

  • Two points: the straight-line distance between them.
  • Point and line: the perpendicular distance from the point to the infinite line through the line segment.
  • Two lines: constrains the lines to be parallel and separated by the given perpendicular distance.
  • Point and circle: the gap between the point and the nearest point on the circle's perimeter, with the point kept outside the circle.
  • Line and circle: the gap between the circle's perimeter and the infinite line through the line segment, with the circle kept to one side of the line.
  • Two circles: the gap between the two perimeters, with each circle kept outside the other.

A point may be ORIGIN, and arcs are treated as the full circle through them.

Arguments

NameTypeDescriptionRequired
points[Segment or Point2d; 2]Two sketch entities, or one sketch entity and ORIGIN, whose separation should match the value set with ==. The order of the entities does not matter.Yes
labelPositionPoint2dOptional position for the displayed constraint label in the sketch's local 2D coordinate system.No

Examples