From fe6ebc528d4067f35537ece8f7ad530bf4bf7a84 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 23 Jun 2018 20:45:49 +0200 Subject: [PATCH] Transform trigonometric formulas to minimize the loss of precision Closes #18142. --- src/common/graphcmn.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/graphcmn.cpp b/src/common/graphcmn.cpp index 817a4311e3..6e3e013bbf 100644 --- a/src/common/graphcmn.cpp +++ b/src/common/graphcmn.cpp @@ -486,9 +486,9 @@ void wxGraphicsPathData::AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, // Determine spatial relation between the vectors. bool drawClockwiseArc = v1.GetCrossProduct(v2) < 0; - alpha = wxDegToRad(alpha) / 2.0; - wxDouble distT = r / sin(alpha) * cos(alpha); - wxDouble distC = r / sin(alpha); + alpha = wxDegToRad(alpha); + wxDouble distT = r / (1.0 + cos(alpha)) * sin(alpha); // = r / tan(a/2) = r / sin(a/2) * cos(a/2) + wxDouble distC = r / sin(alpha / 2.0); wxASSERT_MSG( distT <= v1Length && distT <= v2Length, wxS("Radius is too big to fit the arc to given points") ); // Calculate tangential points