Skip to main content

Midpoint

midpoint holds a point at the middle of a line, or halfway between two other points. A hole that must stay centred on a bar however long the bar becomes is a midpoint, not a distance.

In the viewport

  1. Click a point and a line — or click three points.
  2. Click Midpoint. The constrained point gets an M badge. With three points, the one nearest the middle of the other two becomes the midpoint; pick order does not matter.
The constraint bar with a point and a line picked and the Midpoint button highlighted
A point and a line picked: Midpoint is enabled.
BeforeBefore mode

The hole is drawn off-center, and the anchor point sits away from the middle of the top edge.

AfterAfter modemidpoint(hole.center(), bottom.start(), top.start())

The hole at the tab's center, the anchor at the middle of the top edge.

The code behind it

midpoint(hole.center(), bottom.start(), top.start()) is the three-point form: halfway between two diagonal corners is the tab's center, so the hole stays centred when the tab is resized — no numbers involved. midpoint(anchor, top) is the point–line form. Both remove 2 DOF.

tab.part.js
import { sketch, line, circle, point } from 'fluidcad/core';
import { midpoint, coincident, horizontal, vertical, fix, distance, diameter } from "fluidcad/constraints";

sketch("xy", () => {
// A mounting tab with one hole that must stay in its center however
// the tab is resized.
const bottom = line([0, 0], [50, 0]);
const right = line([50, 0], [50, 30]);
const top = line([50, 30], [0, 30]);
const left = line([0, 30], [0, 0]);
coincident(bottom.end(), right.start());
coincident(right.end(), top.start());
coincident(top.end(), left.start());
coincident(left.end(), bottom.start());
horizontal(bottom);
horizontal(top);
vertical(left);
vertical(right);
fix(bottom.start());
distance(bottom.start(), bottom.end(), 50);
distance(left.start(), left.end(), 30);
// Three-point form: halfway between two diagonal corners IS the
// center of the tab — no numbers needed.
const hole = circle([20, 12], 10);
midpoint(hole.center(), bottom.start(), top.start());
diameter(hole, 10);
// Point + line form: an anchor at the middle of the top edge, where
// a later feature (a rib, a connector) will attach.
const anchor = point([30, 30]);
midpoint(anchor, top);
})

In code

midpoint(p, l) // p at the midpoint of line l: 2 DOF
midpoint(p, a, b) // p halfway between points a and b: 2 DOF
coincident(p, l.mid()) // same as midpoint(p, l)

A datum axis has no midpoint, so it is refused in the line slot.

See also