11 enum class Orientation { LEFT, RIGHT, UP, DOWN };
15 enum class ObjectType {
68 SCHEMATIC_BLOCK_SYMBOL,
71 enum class PatchType { OTHER, TRACK, PAD, PAD_TH, VIA, PLANE, HOLE_PTH, HOLE_NPTH, BOARD_EDGE, TEXT, N_TYPES };
73 extern const LutEnumStr<PatchType> patch_type_lut;
74 extern const LutEnumStr<ObjectType> object_type_lut;
75 extern const LutEnumStr<Orientation> orientation_lut;
85 template <
typename T>
class Coord {
98 Coord(T ix, T iy) : x(ix), y(iy)
104 Coord(std::vector<T> v) : x(v.at(0)), y(v.at(1))
135 bool operator==(
const Coord<T> &a)
const
137 return a.x == x && a.y == y;
139 bool operator!=(
const Coord<T> &a)
const
141 return !(a == *
this);
143 bool operator<(
const Coord<T> &a)
const
157 return Coord<T>(std::min(a.x, b.x), std::min(a.y, b.y));
165 return Coord<T>(std::max(a.x, b.x), std::max(a.y, b.y));
175 static_assert(std::is_floating_point_v<T>);
176 return {r * cos(phi), r * sin(phi)};
181 static_assert(std::is_floating_point_v<T>);
182 const T x2 = x * cos(a) - y * sin(a);
183 const T y2 = x * sin(a) + y * cos(a);
187 Coord<int64_t> to_coordi()
const
189 static_assert(std::is_floating_point_v<T>);
190 return Coord<int64_t>(x, y);
199 return x * a.x + y * a.y;
202 T cross(
const Coord<T> &other)
const
204 return (x * other.y) - (y * other.x);
212 return x * x + y * y;
217 static_assert(std::is_floating_point_v<T>);
221 Coord<T> normalize()
const
223 static_assert(std::is_floating_point_v<T>);
224 return *
this / mag();
229 static_assert(std::is_integral_v<T>);
233 bool in_range(
const Coord<T> &a,
const Coord<T> &b)
const
235 return x > a.x && y > a.y && x < b.x && y < b.y;
238 void operator+=(
const Coord<T> a)
243 void operator-=(
const Coord<T> a)
256 std::array<T, 2> as_array()
const
263 typedef Coord<float> Coordf;
264 typedef Coord<int64_t> Coordi;
265 typedef Coord<double> Coordd;
272 Color(
double ir,
double ig,
double ib) : r(ir), g(ig), b(ib)
277 static Color new_from_int(
unsigned int ir,
unsigned ig,
unsigned ib)
279 return Color(ir / 255.0, ig / 255.0, ib / 255.0);
281 Color() : r(0), g(0), b(0)
291 bool operator<(
const ColorI &other)
const
293 return hashify() < other.hashify();
296 Color to_color()
const
298 return Color::new_from_int(r, g, b);
304 return r | (g << 8) | (b << 16);
308 constexpr
int64_t operator"" _mm(
long double i)
312 constexpr
int64_t operator"" _mm(
unsigned long long int i)
323 enum class CopyMode { DEEP, SHALLOW };
Class SHAPE.
Definition: shape.h:59
Definition: common.hpp:267
Your typical coordinate class.
Definition: common.hpp:85
T dot(const Coord< T > &a) const
Definition: common.hpp:197
T mag_sq() const
Definition: common.hpp:210
static Coord< T > max(const Coord< T > &a, const Coord< T > &b)
Definition: common.hpp:163
static Coord< T > min(const Coord< T > &a, const Coord< T > &b)
Definition: common.hpp:155
static Coord< T > euler(T r, T phi)
Definition: common.hpp:173
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:286
Definition: common.hpp:317