// David Eberly, Geometric Tools, Redmond WA 98052 // Copyright (c) 1998-2020 // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt // Version: 4.0.2019.08.13 #pragma once #include #include // The queries consider the arc to be a 1-dimensional object. namespace WwiseGTE { template class TIQuery, Arc2> { public: struct Result { bool intersect; }; Result operator()(Segment2 const& segment, Arc2 const& arc) { Result result; FIQuery, Arc2> saQuery; auto saResult = saQuery(segment, arc); result.intersect = saResult.intersect; return result; } }; template class FIQuery, Arc2> { public: struct Result { bool intersect; int numIntersections; std::array parameter; std::array, 2> point; }; Result operator()(Segment2 const& segment, Arc2 const& arc) { Result result; result.intersect = false; result.numIntersections = 0; result.parameter[0] = (Real)0; result.parameter[0] = (Real)0; result.point[0] = { (Real)0, (Real)0 }; result.point[1] = { (Real)0, (Real)0 }; FIQuery, Circle2> scQuery; Circle2 circle(arc.center, arc.radius); auto scResult = scQuery(segment, circle); if (scResult.intersect) { // Test whether line-circle intersections are on the arc. for (int i = 0; i < scResult.numIntersections; ++i) { if (arc.Contains(scResult.point[i])) { result.intersect = true; result.parameter[result.numIntersections] = scResult.parameter[i]; result.point[result.numIntersections++] = scResult.point[i]; } } } return result; } }; }