Rounding Errors in primitives? - Printable Version +- LDraw.org Discussion Forums (https://forums.ldraw.org) +-- Forum: General (https://forums.ldraw.org/forum-12.html) +--- Forum: Official File Specifications/Standards (https://forums.ldraw.org/forum-32.html) +--- Thread: Rounding Errors in primitives? (/thread-24515.html) Pages: 1 2 3 RE: Rounding Errors in primitives? - Travis Cobbs - 2021-06-06 (2021-06-06, 11:49)Lasse Deleuran Wrote: But how can we figure out if it is wrong or not? By doing it right and comparing. Compute the X and Z for the given angle using sin and cos and a radius of 1. Round each number to 4 decimal places. Multiply the rounded numbers by the desired radius. RE: Rounding Errors in primitives? - Lasse Deleuran - 2021-06-10 (2021-06-06, 23:16)Travis Cobbs Wrote: By doing it right and comparing. Compute the X and Z for the given angle using sin and cos and a radius of 1. Round each number to 4 decimal places. Multiply the rounded numbers by the desired radius. Here are the calculations: 1)  1-4edge.dat consists of a quarter circle of radius 1 with three points between the end points. The angles of the three points to put into cos and sin in order to get the coordinates of the points are: 1*PI/8 2*PI/8 3*PI/8 cos and sin for the four angles give us the points (note the symmetries and redo these computations by pasting the left hand sides into google): cos(1*PI/8) = 0.92387953251 cos(2*PI/8) = 0.70710678118 cos(3*PI/8) = 0.38268343236 sin(1*PI/8) = 0.38268343236 sin(2*PI/8) = 0.70710678118 sin(3*PI/8) = 0.92387953251 2) Rounding these to 4 decimals 0.92387953251 -> 0.9239 0.70710678118 -> 0.7071 0.38268343236 -> 0.3827 This shows that the values of 1-4edge.dat are correct. The content is copied below for transparency: 2 24 1 0 0 0.9239 0 0.3827 2 24 0.9239 0 0.3827 0.7071 0 0.7071 2 24 0.7071 0 0.7071 0.3827 0 0.9239 2 24 0.3827 0 0.9239 0 0 1 3) Since the points of 1-4edge.dat are correct, the points of 1-4ring5.dat can be computed as in my previous post. Recall that the points of 1-4ring5.dat span from the quarter circle of diameter 5 to the quarter circle of diameter 6: 5 0 0 4.6195 0 1.9135 3.5355 0 3.5355 1.9135 0 4.6195 0 0 5 6 0 0 5.5434 0 2.2962 4.2426 0 4.2426 2.2962 0 5.5434 0 0 6 Which differ from the points in the official file where highlighted. Final calculations done in JS console, by: '1 0 0 0.9239 0 0.3827 0.7071 0 0.7071 0.3827 0 0.9239 0 0 1'.split(' ').map(x => 5*x).join(' '); '1 0 0 0.9239 0 0.3827 0.7071 0 0.7071 0.3827 0 0.9239 0 0 1'.split(' ').map(x => 6*x).join(' '); Shall I start submitting the fixed files to Chris? RE: Rounding Errors in primitives? - Orion Pobursky - 2021-06-10 (2021-06-10, 17:42)Lasse Deleuran Wrote: Shall I start submitting the fixed files to Chris? Go for it with this caveat: We need to look at all the files that use the primitive(s) in question to ensure that they also don't need to be adjusted. RE: Rounding Errors in primitives? - Lasse Deleuran - 2021-06-11 (2021-06-10, 17:59)Orion Pobursky Wrote: Go for it with this caveat: We need to look at all the files that use the primitive(s) in question to ensure that they also don't need to be adjusted. That is a good callout. I will take the files one by one and work on them. Luckily the parts tracker is great at showing dependencies, which helps a lot with this.