| Line |
Branch |
Decision |
Call |
Exec |
Source |
| 1 |
|
|
|
|
#ifndef CHRYSALIS_CONFIG_H |
| 2 |
|
|
|
|
#define CHRYSALIS_CONFIG_H |
| 3 |
|
|
|
|
|
| 4 |
|
|
|
|
#include <CGAL/Exact_circular_kernel_2.h> |
| 5 |
|
|
|
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> |
| 6 |
|
|
|
|
|
| 7 |
|
|
|
|
#include <optional> |
| 8 |
|
|
|
|
|
| 9 |
|
|
|
|
namespace Chrysalis::CG { |
| 10 |
|
|
|
|
|
| 11 |
|
|
|
|
// --- Constants --------------------------------------------------------------------------------------------------- |
| 12 |
|
|
|
|
|
| 13 |
|
|
|
|
static constexpr auto PRECISION = 15; |
| 14 |
|
|
|
|
|
| 15 |
|
|
|
|
// --- CGAL Types -------------------------------------------------------------------------------------------------- |
| 16 |
|
|
|
|
|
| 17 |
|
|
|
|
using LinearKernel = CGAL::Exact_predicates_inexact_constructions_kernel; |
| 18 |
|
|
|
|
using CircularKernel = CGAL::Exact_circular_kernel_2; |
| 19 |
|
|
|
|
|
| 20 |
|
|
|
|
using Transformation = CGAL::Aff_transformation_2<LinearKernel>; |
| 21 |
|
|
|
|
|
| 22 |
|
|
|
|
using Ray = CGAL::Ray_2<LinearKernel>; |
| 23 |
|
|
|
|
using Line = CGAL::Line_2<LinearKernel>; |
| 24 |
|
|
|
|
using Point = CGAL::Point_2<LinearKernel>; |
| 25 |
|
|
|
|
using Vector = CGAL::Vector_2<LinearKernel>; |
| 26 |
|
|
|
|
using Segment = CGAL::Segment_2<LinearKernel>; |
| 27 |
|
|
|
|
|
| 28 |
|
|
|
|
using CPoint = CGAL::Point_2<CircularKernel>; |
| 29 |
|
|
|
|
using Circle = CGAL::Circle_2<CircularKernel>; |
| 30 |
|
|
|
|
using CArcPoint = CGAL::Circular_arc_point_2<CircularKernel>; |
| 31 |
|
|
|
|
|
| 32 |
|
|
|
|
using CCIntersection = CGAL::CK2_Intersection_traits<CircularKernel, Circle, Circle>::type; |
| 33 |
|
|
|
|
|
| 34 |
|
|
|
|
// === Functions =================================================================================================== |
| 35 |
|
|
|
|
|
| 36 |
|
|
|
|
double sin(double value); |
| 37 |
|
|
|
|
double cos(double value); |
| 38 |
|
|
|
|
double round(double value); |
| 39 |
|
|
|
|
double radians(double degrees); |
| 40 |
|
|
|
|
Vector rotate(const Vector& vector, double angle); |
| 41 |
|
|
|
|
double angle(const Vector& vector1, const Vector& vector2); |
| 42 |
|
|
|
|
double angle(const Point& pointFrom, const Point& pointTo); |
| 43 |
|
|
|
|
double length(const Point& pointFrom, const Point& pointTo); |
| 44 |
|
|
|
|
Point mirror(const Point& point, const Point& center); |
| 45 |
|
|
|
|
Point relativePoint(const Point& pointFrom, const Vector& vector); |
| 46 |
|
|
|
|
Point relativePoint(const Point& pointFrom, double angle, double length); |
| 47 |
|
|
|
|
Point projection(const Point& point, const Line& line); |
| 48 |
|
|
|
|
template<typename T1, typename T2> |
| 49 |
|
|
|
18 |
std::optional<Point> intersection(const T1& obj1, const T2& obj2) { |
| 50 |
0/2
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
|
0/2
✗ Call 0 not invoked.
✗ Call 1 not invoked.
|
18 |
const auto intersection = CGAL::intersection(obj1, obj2); |
| 51 |
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
0/2
✗ Call 0 not invoked.
✗ Call 3 not invoked.
|
18 |
if (!intersection) return std::nullopt; |
| 52 |
|
|
0/2
✗ Call 0 not invoked.
✗ Call 1 not invoked.
|
18 |
const Point* point = std::get_if<Point>(&*intersection); |
| 53 |
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
|
0/3
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
|
18 |
return point ? std::optional(*point) : std::nullopt; |
| 54 |
|
|
|
|
} |
| 55 |
|
|
|
|
std::optional<Point> xIntersection(const Point& pointFrom, const Point& pointTo); |
| 56 |
|
|
|
|
std::optional<Point> yIntersection(const Point& pointFrom, const Point& pointTo); |
| 57 |
|
|
|
|
Point circlesIntersection(const Point& anchor, CPoint center1, double radius1, CPoint center2, double radius2); |
| 58 |
|
|
|
|
|
| 59 |
|
|
|
|
} |
| 60 |
|
|
|
|
|
| 61 |
|
|
|
|
#endif //CHRYSALIS_CONFIG_H |
| 62 |
|
|
|
|
|