Rounding Errors in primitives?


RE: Rounding Errors in primitives?
#22
(2021-06-06, 23:16)Travis Cobbs Wrote: By doing it right and comparing.

  1. Compute the X and Z for the given angle using sin and cos and a radius of 1.
  2. Round each number to 4 decimal places.
  3. 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?
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: Rounding Errors in primitives? - by Lasse Deleuran - 2021-06-10, 17:42

Forum Jump:


Users browsing this thread: 1 Guest(s)