MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / caliper

Class caliper

code/geometry/rotating_calipers.cpp:2–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "lines.cpp"
2struct caliper {
3 ii pt;
4 double angle;
5 caliper(ii _pt, double _angle) : pt(_pt), angle(_angle) { }
6 double angle_to(ii pt2) {
7 double x = angle - atan2(pt2.second - pt.second,
8 pt2.first - pt.first);
9 while (x >= pi) x -= 2*pi;
10 while (x <= -pi) x += 2*pi;
11 return x; }
12 void rotate(double by) {
13 angle -= by;
14 while (angle < 0) angle += 2*pi; }
15 void move_to(ii pt2) { pt = pt2; }
16 double dist(const caliper &other) {
17 point a(pt.first,pt.second),
18 b = a + exp(point(0,angle)) * 10.0,
19 c(other.pt.first, other.pt.second);
20 return abs(c - closest_point(a, b, c)); } };
21// int h = convex_hull(pts);
22// double mx = 0;
23// if (h > 1) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected