Question about creating a primitive


Question about creating a primitive
#1
Hello,

I would like to create a new primitive (4-4ring179.dat).
To do this, I looked at the primitive 4-4ring18.dat. I noticed that the values of the individual points are, in my opinion, incorrect.
A quarter circle consists of four circle segments. The angle of each piece of the quarter circle is 22.5°.
The first line in the primitive file looks like this:

4 16 19 0 0 17.5541 0 7.2713 16.6302 0 6.8886 18 0 0

19 0 0 is the point at the bottom right of the first circular arc segment. For the second point counterclockwise, the following applies:

x = cos(22.5°) * 19 ~ 0.923879 * 19 ~ 17.55371111 -> 17.5537
y = sin(22.5°) * 19 ~ 0.382683 * 19 ~ 7.27098521 -> 7.2709

These values differ from the values in the file.
The deviation is very small, but it is there.


My question is: is the value in the file correct and I have made a mistake in my thinking? If so, what is it?  Sad

Best regards,

Manfred
Reply
RE: Question about creating a primitive
#2
I think the "inaccuracies" are from the process/definition of the prims...
a ring18 connects a cyl scaled x18 with one scaled x19, which means the rounding imperfections from the cyl prims get amplified.
(I dont know exactly but it fits: edge/cyl prims have 0.9239 0 0.3827 for the 22.5° position, this multiplied with 19 results in your 17.5541 0 7.2713 values)
Reply
RE: Question about creating a primitive
#3
Your thinking is right, it's a question of rounding method. We calculate sin/cos of angle, then round these value to 4 decimal places, then scale these values by iner/ourter ring value. This order may seem weird at first sight as it actually lowers the precision, but it's done this way so that the vertices of a cylinder or and edge primitives (that have a 1.0 radius) exactly matches the ones of rings when scaled to fit the ring.

Note that Primgen2 tool (either standalone or integrated into LDPE) manages all this for you Wink

...and the real question: why do you need such a large ring radius?
Reply
RE: Question about creating a primitive
#4
(2026-01-02, 19:07)Philippe Hurbain Wrote: Your thinking is right, it's a question of rounding method. We calculate sin/cos of angle, then round these value to 4 decimal places, then scale these values by iner/ourter ring value. This order may seem weird at first sight as it actually lowers the precision, but it's done this way so that the vertices of a cylinder or and edge primitives (that have a 1.0 radius) exactly matches the ones of rings when scaled to fit the ring.

Note that Primgen2 tool (either standalone or integrated into LDPE) manages all this for you Wink

...and the real question: why do you need such a large ring radius?

Hello,
Thank you for the explanation, now I understand the background.
The answer to the question of why I need such a large ring is that I need it as a border for a round sticker. It will be scaled down by a factor of 10 beforehand. The actual ring would then only be 0.1 LDU wide.
I just saw that I can also use the primitive n-fedge, since I still need the edge line. On the inside, I'm working with n-fchrd.dat for the transition from the edge to the pattern.
Reply
RE: Question about creating a primitive
#5
(2026-01-02, 19:06)Rene Rechthaler Wrote: I think the "inaccuracies" are from the process/definition of the prims...
a ring18 connects a cyl scaled x18 with one scaled x19, which means the rounding imperfections from the cyl prims get amplified.
(I dont know exactly but it fits: edge/cyl prims have 0.9239 0 0.3827 for the 22.5° position, this multiplied with 19 results in your 17.5541 0 7.2713 values)


Hello,

Thanks for your reply. Philippe's explanation has helped me understand why rounding errors are accepted and why this approach makes sense.
The primitives are defined as size one and can be scaled by any factor; the error that results from this is the same for all primitives. This is different from when rounding is only performed at the end.
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 1 Guest(s)