58 auto furthestFromIntersect =
61 if( ( aPt1 - intersectPoint ).EuclideanNorm()
72 auto closestToIntersect =
75 if( ( aPt1 - intersectPoint ).EuclideanNorm()
94 VECTOR2I midPt = perpendicularAtoB.Center();
100 std::vector<VECTOR2I> possibleCenters =
IntersectLine( anglebisector );
102 wxCHECK_MSG( possibleCenters.size() > 0, *
this, wxT(
"No solutions exist!" ) );
103 intersectPoint = aLineA.
A;
107 Center = closestToIntersect( possibleCenters.front(), possibleCenters.back() );
115 wxCHECK_MSG( intersectCalc, *
this, wxT(
"Lines do not intersect but are not parallel?" ) );
116 intersectPoint = intersectCalc.get();
118 if( aP == intersectPoint )
127 VECTOR2I lineApt = furthestFromIntersect( aLineA.
A, aLineA.
B );
128 VECTOR2I lineBpt = furthestFromIntersect( aLineB.
A, aLineB.
B );
131 anglebisector.
A = intersectPoint;
132 anglebisector.
B = bisectorPt;
140 SEG throughaP( intersectPoint, aP );
141 std::vector<VECTOR2I> hProjections = hSolution.
IntersectLine( throughaP );
142 wxCHECK_MSG( hProjections.size() > 0, *
this, wxT(
"No solutions exist!" ) );
146 VECTOR2I hSelected = closestToIntersect( hProjections.front(), hProjections.back() );
155 SEG hT( hTanLineA, hSelected );
157 wxCHECK_MSG( actTanA, *
this, wxT(
"No solutions exist!" ) );
162 wxCHECK_MSG( actCenter, *
this, wxT(
"No solutions exist!" ) );
170 SEG hT( hTanLineB, hSelected );
172 wxCHECK_MSG( actTanB, *
this, wxT(
"No solutions exist!" ) );
177 wxCHECK_MSG( actCenter, *
this, wxT(
"No solutions exist!" ) );
202 if( vec.
x == 0 && vec.
y == 0 )
232 std::vector<VECTOR2I> retval;
237 int64_t r2 = aCircle.
Radius;
239 if( d > ( r1 + r2 ) || ( d < ( std::abs( r1 - r2 ) ) ) )
246 int64_t x = ( ( d * d ) + ( r1 * r1 ) - ( r2 * r2 ) ) / ( int64_t( 2 ) * d );
247 int64_t r1sqMinusXsq = ( r1 * r1 ) - ( x * x );
249 if( r1sqMinusXsq < 0 )
253 int64_t y =
KiROUND( sqrt( r1sqMinusXsq ) );
256 double rotAngle = vecCtoC.
Angle();
258 solution1 = solution1.
Rotate( rotAngle );
260 retval.push_back( solution1 );
265 solution2 = solution2.
Rotate( rotAngle );
267 retval.push_back( solution2 );
276 std::vector<VECTOR2I> retval;
281 retval.push_back( intersection );
290 std::vector<VECTOR2I> retval;
324 retval.push_back( m );
328 int64_t radiusSquared = (int64_t)
Radius * (int64_t)
Radius;
329 int64_t omDistSquared = omDist * omDist;
331 int mTo1dist = sqrt( radiusSquared - omDistSquared );
333 VECTOR2I mTo1vec = ( aLine.
B - aLine.
A ).Resize( mTo1dist );
336 retval.push_back( mTo1vec + m );
337 retval.push_back( mTo2vec + m );
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
const VECTOR2I CalcArcMid(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, bool aMinArcAngle=true)
Return the middle point of an arc, half-way between aStart and aEnd.
SEG PerpendicularSeg(const VECTOR2I &aP) const
Compute a segment perpendicular to this one, passing through point aP.
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Compute the intersection point of lines passing through ends of (this) and aSeg.
int LineDistance(const VECTOR2I &aP, bool aDetermineSide=false) const
Return the closest Euclidean distance between point aP and the line defined by the ends of segment (t...
SEG ParallelSeg(const VECTOR2I &aP) const
Compute a segment parallel to this one, passing through point aP.
CIRCLE & ConstructFromTanTanPt(const SEG &aLineA, const SEG &aLineB, const VECTOR2I &aP)
Construct this circle such that it is tangent to the given segments and passes through the given poin...
bool ApproxParallel(const SEG &aSeg, int aDistanceThreshold=1) const
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
OPT< VECTOR2I > OPT_VECTOR2I
static const int MIN_PRECISION_IU
This is the minimum precision for all the points in a shape.
std::vector< VECTOR2I > IntersectLine(const SEG &aLine) const
Compute the intersection points between this circle and aLine.
int Radius
Public to make access simpler.
Represent basic circle geometry with utility geometry functions.
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
double Angle() const
Compute the angle of the vector.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
VECTOR2< T > Rotate(double aAngle) const
Rotate the vector by a given angle.
std::vector< VECTOR2I > Intersect(const CIRCLE &aCircle) const
Compute the intersection points between this circle and aCircle.
bool Contains(const VECTOR2I &aP) const
Return true if aP is on the circumference of this circle.
VECTOR2I Center
Public to make access simpler.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute the point on the circumference of the circle that is the closest to aP.
bool Contains(const SEG &aSeg) const