[SOLVED] polyline bulge

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
User avatar
petevick
Premier Member
Posts: 392
Joined: Tue May 19, 2020 9:34 am
Location: North Norfolk coast UK

[SOLVED] polyline bulge

Post by petevick » Thu Dec 29, 2022 11:07 am

I'm using addPolyline() in a script I'm playing with, I want a known radius on a section of the polyline that will always be at 90degs. At the moment I add a section of polyline at 45degs and I then use the bulge option, and with trial and error I know that a bulge of 0.42 gives a radius of 5. But for a radius of 20 the bulge is 0.413. Is there a known equation that would give the correct bulge for any given radius ?? The desired result as below.
ksnip_20221229-100300.png
ksnip_20221229-100300.png (3.54 KiB) Viewed 6520 times
Last edited by petevick on Sat Dec 31, 2022 7:29 pm, edited 1 time in total.
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Qcad Pro 3.29.6

User avatar
petevick
Premier Member
Posts: 392
Joined: Tue May 19, 2020 9:34 am
Location: North Norfolk coast UK

Re: polyline bulge

Post by petevick » Thu Dec 29, 2022 11:28 am

I'm answering my own question. It will always be 0.4142 as the bulge is based on the radius angle, so in my case it's tangent(90/4) = 0.4142
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Qcad Pro 3.29.6

CVH
Premier Member
Posts: 3467
Joined: Wed Sep 27, 2017 4:17 pm

Re: polyline bulge

Post by CVH » Thu Dec 29, 2022 8:30 pm

petevick wrote:
Thu Dec 29, 2022 11:28 am
It will always be 0.4142 as the bulge is based on the radius angle, so in my case it's tangent(90/4) = 0.4142
Indeed and not quite correct.

If you use the simple API then arcs are in degrees, the API converts them in radians.
But if you script without the use of the simple API or input.js then radians are required.
(I know, with the QCAD GUI active, input.js is always loaded but the advise is not to use that.)

For a perfect 90 degrees bulge (As good as it gets) the answer is the mathematical expression and not the rounded value.
input.js : tan(90/4) or better Math.tan(RMath.deg2rad(90/4)) or Math.tan(Math.PI/8) ...
All those are equal to sqrt(2)-1 :wink: and then it is a simple sum because Math.SQRT2 is a predefined value.

As you have noticed, the radius is not accounted for ...
... So for rounded bulging factors the absolute radius error grows with the distance between the nodes (The arc chord).

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”