Rounding bug in PrimGen2?


Rounding bug in PrimGen2?
#1
Hej,
I think, I found a rounding problem in PrimGen2.
I'll continue to check all primitives for rounding errors, correct file ending and add a "generated with primgen" comment, when comparison is successful or the file is regenerated.
Please see these lines:
Code:
0 Cone 15 x 0.25
0 Name: 1-4con15.dat
0 Author: Max Martin Richter [MMR1988]
0 !LDRAW_ORG Unofficial_Primitive
0 !LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt

0 BFC CERTIFY CCW

4 16 15 1 0 [color=#FF0000]13.8585 1 5.7405[/color] 14.7824 0 6.1232 16 0 0
4 16 13.8585 1 5.7405 10.6065 1 10.6065 11.3136 0 11.3136 14.7824 0 6.1232
4 16 10.6065 1 10.6065 [color=#FF00CC]5.7405 1 13.8585[/color] 6.1232 0 14.7824 11.3136 0 11.3136
4 16 5.7405 1 13.8585 0 1 15 0 0 16 6.1232 0 14.7824
0 // conditional lines
5 24 15 1 0 16 0 0 15 1 -6.2132 [color=#FF0000]13.8582 1 5.7403[/color]
5 24 13.8585 1 5.7405 14.7824 0 6.1232 15 1 0 10.6066 1 10.6066
5 24 10.6065 1 10.6065 11.3136 0 11.3136 13.8582 1 5.7403 [color=#FF00CC]5.7403 1 13.8582[/color]
5 24 5.7405 1 13.8585 6.1232 0 14.7824 10.6066 1 10.6066 0 1 15
5 24 0 1 15 0 0 16 5.7403 1 13.8582 -6.2132 1 15
0 // Build by Primitive Generator 2

This problem seem to exist for cones only...

/Max
Reply
Re: Rounding bug in PrimGen2?
#2
Indeed, problem lies in condlines values that are not rounded properly. The algorithm to get proper values for cones is
sine(angle) rounded to 4 decimal places, multiplied by radius. This is done properly for quads, but condlines use sine(angle) multiplied by radius, rounded to 4dp. The rounding scheme may seem weird at first sight, but it ensures a perfect match with edges/discs that have a unit size, are rounded to 4dp and scaled to size when used.
Reply
Re: Rounding bug in PrimGen2?
#3
After thinking over this problem again I would suggest the following solution:
Change the calculation algorithm of the condline values to the algorithm of the quads values. This will not cause in hairline gaps for parts and changing the condlines will not result in any problems for the existing parts.

/Max
Reply
Re: Rounding bug in PrimGen2?
#4
Yes, that's correct - round first, then multiply by radius.
Chris (LDraw Parts Library Admin)
Reply
Re: Rounding bug in PrimGen2?
#5
Are these lines better:
0 Name: 1-4con15.dat
0 Author: Michael Heidemann [mikeheide]
0 !LDRAW_ORG Unofficial_Primitive
0 !LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt

0 BFC CERTIFY CCW

4 16 15 1 0 13.8585 1 5.7405 14.7824 0 6.1232 16 0 0
4 16 13.8585 1 5.7405 10.6065 1 10.6065 11.3136 0 11.3136 14.7824 0 6.1232
4 16 10.6065 1 10.6065 5.7405 1 13.8585 6.1232 0 14.7824 11.3136 0 11.3136
4 16 5.7405 1 13.8585 0 1 15 0 0 16 6.1232 0 14.7824
0 // conditional lines
5 24 15 1 0 16 0 0 15 1 -6.213 13.8585 1 5.7405
5 24 13.8585 1 5.7405 14.7824 0 6.1232 15 1 0 10.6065 1 10.6065
5 24 10.6065 1 10.6065 11.3136 0 11.3136 13.8585 1 5.7405 5.7405 1 13.8585
5 24 5.7405 1 13.8585 6.1232 0 14.7824 10.6065 1 10.6065 0 1 15
5 24 0 1 15 0 0 16 5.7405 1 13.8585 -6.213 1 15
0 // Build by Primitive Generator 2

I had indeed forgot to use the rounding for the third and fourth vertice on optional lines. Sorry!
Reply
Re: Rounding bug in PrimGen2?
#6
Yes, this seems to work.
Do you prepare an update of PrimGen?

/Max
Reply
Re: Rounding bug in PrimGen2?
#7
Now, after I got a proof that my bugfix is correct - YES. Maybe tomorrow. Wink
Reply
Re: Rounding bug in PrimGen2?
#8
Now since it only affect control points to less than the 3rd dp, the effect is completely unnoticeable!!!
Reply
Re: Rounding bug in PrimGen2?
#9
Yes, it is. But it is weird to have different values for the control points than for the quads.
/Max
Reply
Re: Rounding bug in PrimGen2?
#10
The new version is online at http://ldraw.heidemann.org/index.php?page=primgen2

Have fun Smile
Reply
Re: Rounding bug in PrimGen2?
#11
Good that I finished the Wheels and Tyres, last night...
Only the code pilot needs some more attention - but I'll check the prims first...

/Max
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 1 Guest(s)