Bug 121425 - Increase accuracy of circle approximation by Bézier curves
Summary: Increase accuracy of circle approximation by Bézier curves
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
6.2.0.0.alpha1+
Hardware: x86-64 (AMD64) Windows (All)
: medium enhancement
Assignee: Regina Henschel
URL:
Whiteboard: target:6.3.0
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-14 19:07 UTC by Regina Henschel
Modified: 2018-11-24 16:47 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
ApproxCircleInfo.odt, Artical about the mathematics to be used (257.69 KB, application/vnd.oasis.opendocument.text)
2018-11-14 19:07 UTC, Regina Henschel
Details
Custom shape circle to make your own experiments (13.39 KB, application/vnd.oasis.opendocument.graphics)
2018-11-14 19:09 UTC, Regina Henschel
Details
Legacy circle to make your own experiments (13.19 KB, application/vnd.oasis.opendocument.graphics)
2018-11-14 19:10 UTC, Regina Henschel
Details
Essential parts of my intended changes. (2.35 KB, patch)
2018-11-14 19:21 UTC, Regina Henschel
Details
Approximate a circle arc by a Bézier curce, formulas and examples (275.65 KB, application/vnd.oasis.opendocument.text)
2018-11-16 12:02 UTC, Regina Henschel
Details
Proposed patch (7.20 KB, patch)
2018-11-16 19:05 UTC, Regina Henschel
Details
Approximate a circle arc by a Bézier curce, formulas and examples (275.07 KB, application/vnd.oasis.opendocument.text)
2018-11-17 13:43 UTC, Regina Henschel
Details
Approximate a circle arc by a Bézier curce, formulas and examples (294.41 KB, application/vnd.oasis.opendocument.text)
2018-11-20 14:08 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2018-11-14 19:07:34 UTC
Created attachment 146629 [details]
ApproxCircleInfo.odt, Artical about the mathematics to be used

The circle primitive is drawn by an approximation with twelve Bézier curves. The value chosen for the distance between control point and end point can be improved. For details about the calculation read the attached document "ApproxCircleInfo.odt".
Comment 1 Regina Henschel 2018-11-14 19:09:16 UTC
Created attachment 146630 [details]
Custom shape circle to make your own experiments
Comment 2 Regina Henschel 2018-11-14 19:10:04 UTC
Created attachment 146631 [details]
Legacy circle to make your own experiments
Comment 3 Regina Henschel 2018-11-14 19:21:33 UTC
Created attachment 146632 [details]
Essential parts of my intended changes.

@Armin: The patch contains the intended changes. Please have a look. The final solution will have changes in the description of the functions in regard to accuracy. The current wording "less than 0.5 percent" needs to be adapted, in case you agree with my proposal.
Comment 4 Regina Henschel 2018-11-16 12:02:55 UTC
Created attachment 146683 [details]
Approximate a circle arc by a Bézier curce, formulas and examples

Describes the general problem and contains a formula to calculate the control points of the Bézier curve.
Comment 5 Regina Henschel 2018-11-16 19:05:50 UTC
Created attachment 146696 [details]
Proposed patch

@Armin: Please have a look at the attached patch.
It uses factors for the vector from Bézier point to the associated control point, which is calculated from the actual center angle and not by scaling the value from the 90°-factor. Thus I have renamed fScaledKappa to fSegmentKappa.
Currently the calculation of the factor is done in a local function. My question: Do similar calculations exist for to approximate a circle with a Bézier curve somewhere outside this file? In that case it might be useful, to make it a public function.
Because of the small resolution of screens, you should export test files to pdf and examine the resulting file e.g. with Acrobat Reader at 6400% zoom.
Comment 6 Regina Henschel 2018-11-17 13:43:28 UTC
Created attachment 146704 [details]
Approximate a circle arc by a Bézier curce, formulas and examples
Comment 7 Regina Henschel 2018-11-20 14:08:14 UTC
Created attachment 146836 [details]
Approximate a circle arc by a Bézier curce, formulas and examples

Document as mentioned in the patch.

The final patch is now in https://gerrit.libreoffice.org/#/c/63659/ and waiting for review.
Comment 8 Commit Notification 2018-11-22 17:57:05 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/fbc95e77d28f8a5a8f6442a64e5e0e52e98612c2%5E%21

tdf#121425 Use better Bezier curves to approximate circle arc

It will be available in 6.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Regina Henschel 2018-11-24 16:47:31 UTC
Fixed in Version: 6.3.0.0.alpha0+ (x64)
Build ID: 70970f8b72eddc66693ec28d26c2dc764009d3e3
CPU threads: 8; OS: Windows 10.0; UI render: GL; VCL: win; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2018-11-24_03:32:27
Locale: en-US (en_US); UI-Language: en-US
Calc: threaded