TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
coupling.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// Coupled segments of a differential pair, as KiCad 10.0.6's diff-pair coupling test finds them
4// (pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp, doc 05 §59): a track of the P net and one of the N net on the same
5// layer are coupled where they run on parallel, distinct lines and their projections overlap. The gap is measured between the
6// overlapping parts, edge to edge. Integer arithmetic follows KiCad's SEG (rounded rescale, truncated square root), so the
7// gap is KiCad's to the nanometre.
8
9#include <optional>
10
11#include "model/board.hpp"
12
13namespace tmk::drc {
14
15struct Coupling {
16 model::Point pa, pb, na, nb; // the overlapping parts of the P and N centrelines
17 model::Point near_p, near_n; // their nearest points
18 Coord gap = 0; // edge to edge: centreline distance minus the half widths
19 Coord length = 0; // length of the N part, rounded
20};
21
22// The two centrelines (a P track from p0 to p1 of width wp, an N track likewise) coupled as KiCad couples them, or nothing: both
23// longer than about 1 nm, exactly parallel (a zero cross product) and not collinear, with overlapping projections.
24std::optional<Coupling> couple(model::Point p0, model::Point p1, Coord wp, model::Point n0, model::Point n1, Coord wn);
25
26} // namespace tmk::drc
The board model (design doc 02 §3): every object TraceMaker reads from a .kicad_pcb,...
std::optional< Coupling > couple(model::Point p0, model::Point p1, Coord wp, model::Point n0, model::Point n1, Coord wn)
The two centrelines (a P track from p0 to p1 of width wp, an N track likewise) coupled as KiCad coupl...
std::int64_t Coord
Engine coordinate: signed 64-bit nanometres.
Definition units.hpp:12
model::Point near_p
Definition coupling.hpp:17
model::Point pa
Definition coupling.hpp:16
Coord length
length of the N part, rounded
Definition coupling.hpp:19
model::Point near_n
their nearest points
Definition coupling.hpp:17
model::Point pb
Definition coupling.hpp:16
Coord gap
edge to edge: centreline distance minus the half widths
Definition coupling.hpp:18
model::Point na
Definition coupling.hpp:16
model::Point nb
the overlapping parts of the P and N centrelines
Definition coupling.hpp:16