/** * \file * \copyright * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org) * Distributed under a Modified BSD License. * See accompanying file LICENSE.txt or * http://www.opengeosys.org/project/license */ #pragma once #include #include #include #include #include #include "GeoLib/LineSegment.h" #include "MathLib/Point3d.h" namespace autocheck { // generates points on a circle in x-y plane template > struct RandomCirclePointGeneratorXY { explicit RandomCirclePointGeneratorXY( MathLib::Point3d const& c = MathLib::Point3d{std::array{ {0, 0, 0}}}, double r = 1.0) : center(c), radius(r) {} using result_type = MathLib::Point3d; result_type operator()(std::size_t /*size*/ = 0) { // generates uniformly distributed values in the interval [-4, 4] auto const angle(generator(4)); return MathLib::Point3d{ std::array{{center[0] + radius * std::cos(angle), center[1] + radius * std::sin(angle), 0.0}}}; } Gen generator; MathLib::Point3d const center; double const radius; }; // reflect point p on the point c in x-y plane MathLib::Point3d reflect(MathLib::Point3d const& c, MathLib::Point3d const& p); // generates line segments that are special chords of a circle, i.e. the chords // include the circle centre point. template >> struct SymmSegmentGeneratorXY { SymmSegmentGeneratorXY( Gen s, std::function f) : source(std::move(s)), function(std::move(f)) {} using result_type = GeoLib::LineSegment; result_type operator()(std::size_t /*size*/ = 0) { std::unique_ptr a{new GeoLib::Point{source(), 0}}; std::unique_ptr b{new GeoLib::Point{function(*a), 1}}; return result_type{a.release(), b.release(), true}; } Gen source; std::function function; }; GeoLib::LineSegment translate(Eigen::Vector3d const& translation, GeoLib::LineSegment const& line_seg); template >>> struct PairSegmentGeneratorXY { PairSegmentGeneratorXY( Gen s, std::function f) : segment_generator(std::move(s)), function(std::move(f)) { } using result_type = std::pair; result_type operator()(std::size_t /*size*/ = 0) { auto first = segment_generator(); auto second = function(first); return result_type{first, second}; } Gen segment_generator; std::function function; }; } // namespace autocheck