[SOLVED] polyline bulge
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
- petevick
- Premier Member
- Posts: 392
- Joined: Tue May 19, 2020 9:34 am
- Location: North Norfolk coast UK
[SOLVED] polyline bulge
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.
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
Linux Mint 21.2 Cinnamon, Qcad Pro 3.29.6
- petevick
- Premier Member
- Posts: 392
- Joined: Tue May 19, 2020 9:34 am
- Location: North Norfolk coast UK
Re: polyline bulge
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
Linux Mint 21.2 Cinnamon, Qcad Pro 3.29.6
Re: polyline bulge
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 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