11 enum class Orientation { LEFT, RIGHT, UP, DOWN };
15 enum class ObjectType {
64 enum class PatchType { OTHER, TRACK, PAD, PAD_TH, VIA, PLANE, HOLE_PTH, HOLE_NPTH, BOARD_EDGE, TEXT, N_TYPES };
66 extern const LutEnumStr<PatchType> patch_type_lut;
67 extern const LutEnumStr<ObjectType> object_type_lut;
68 extern const LutEnumStr<Orientation> orientation_lut;
78 template <
typename T>
class Coord {
91 Coord(T ix, T iy) : x(ix), y(iy)
97 Coord(std::vector<T> v) : x(v.at(0)), y(v.at(1))
128 bool operator==(
const Coord<T> &a)
const
130 return a.x == x && a.y == y;
132 bool operator!=(
const Coord<T> &a)
const
134 return !(a == *
this);
136 bool operator<(
const Coord<T> &a)
const
150 return Coord<T>(std::min(a.x, b.x), std::min(a.y, b.y));
158 return Coord<T>(std::max(a.x, b.x), std::max(a.y, b.y));
168 static_assert(std::is_floating_point_v<T>);
169 return {r * cos(phi), r * sin(phi)};
174 static_assert(std::is_floating_point_v<T>);
175 const T x2 = x * cos(a) - y * sin(a);
176 const T y2 = x * sin(a) + y * cos(a);
180 Coord<int64_t> to_coordi()
const
182 static_assert(std::is_floating_point_v<T>);
183 return Coord<int64_t>(x, y);
192 return x * a.x + y * a.y;
195 T cross(
const Coord<T> &other)
const
197 return (x * other.y) - (y * other.x);
205 return x * x + y * y;
210 static_assert(std::is_floating_point_v<T>);
214 Coord<T> normalize()
const
216 static_assert(std::is_floating_point_v<T>);
217 return *
this / mag();
222 static_assert(std::is_integral_v<T>);
226 bool in_range(
const Coord<T> &a,
const Coord<T> &b)
const
228 return x > a.x && y > a.y && x < b.x && y < b.y;
231 void operator+=(
const Coord<T> a)
236 void operator-=(
const Coord<T> a)
249 std::array<T, 2> as_array()
const
256 typedef Coord<float> Coordf;
257 typedef Coord<int64_t> Coordi;
258 typedef Coord<double> Coordd;
265 Color(
double ir,
double ig,
double ib) : r(ir), g(ig), b(ib)
270 static Color new_from_int(
unsigned int ir,
unsigned ig,
unsigned ib)
272 return Color(ir / 255.0, ig / 255.0, ib / 255.0);
274 Color() : r(0), g(0), b(0)
284 bool operator<(
const ColorI &other)
const
286 return hashify() < other.hashify();
289 Color to_color()
const
291 return Color::new_from_int(r, g, b);
297 return r | (g << 8) | (b << 16);
301 constexpr
int64_t operator"" _mm(
long double i)
305 constexpr
int64_t operator"" _mm(
unsigned long long int i)
316 enum class CopyMode { DEEP, SHALLOW };
Class SHAPE.
Definition: shape.h:59
Definition: common.hpp:260
Your typical coordinate class.
Definition: common.hpp:78
T dot(const Coord< T > &a) const
Definition: common.hpp:190
T mag_sq() const
Definition: common.hpp:203
static Coord< T > max(const Coord< T > &a, const Coord< T > &b)
Definition: common.hpp:156
static Coord< T > min(const Coord< T > &a, const Coord< T > &b)
Definition: common.hpp:148
static Coord< T > euler(T r, T phi)
Definition: common.hpp:166
zip_int64_t int64_t
zip_int64_t typedef.
Definition: zip.hpp:103
zip_uint32_t uint32_t
zip_uint32_t typedef.
Definition: zip.hpp:98
zip_uint8_t uint8_t
zip_uint8_t typedef.
Definition: zip.hpp:78
Definition: common.hpp:279
Definition: common.hpp:310