MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / rectangle_corners

Function rectangle_corners

src/svgfill/src/arrange_polygons.cpp:1013–1024  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1011}
1012
1013std::array<DPoint, 4> rectangle_corners(const DPoint& start, const DPoint& end, double width) {
1014 auto u = unit(end - start);
1015 if (u.squared_length() < 1.e-18) {
1016 u = {1., 0.};
1017 }
1018 auto n = perpendicular(u);
1019 auto ext = width;
1020 auto p0 = start - u * ext;
1021 auto p1 = end + u * ext;
1022 auto w = n * (width / 2.);
1023 return {p0 + w, p1 + w, p1 - w, p0 - w};
1024}
1025
1026DBox aabb_from_points(const std::array<DPoint, 4>& corners) {
1027 DBox bbox{corners[0], corners[0]};

Callers 3

build_run_box_recordsFunction · 0.85
merge_cluster_to_boxFunction · 0.85
join_segment_runsFunction · 0.85

Calls 2

perpendicularFunction · 0.85
unitFunction · 0.70

Tested by

no test coverage detected