Precision when serializing degrees
On 15/07/2013 at 15:47, xxxxxxxx wrote:
Cinema 4D Version: R13-R14
Platform: Windows ;
Language(s) : C++ ;
I am serializing an object (storing its parameters as a string and reading them back again from the string).
For degree values, I do not get the precision I want.
20° becomes 0.349 which then becomes 19.996 °
30° becomes 0.524 which then becomes 30.023 °
45° becomes 0.785 which then becomes 44.977 °
This will probably have no practical meaning, but it somehow looks "ugly" when you want a precise common value.
I use RealToString() forwards and ToReal() to get the value back again.
Is there a way to get more precision?
On 15/07/2013 at 16:32, xxxxxxxx wrote:
Rotations are typically stored as Radians and not degrees ('becomes'). What you should do is maybe store the degree value and do the conversion back to radians when you read the information back to set the rotation values. Floating point is inprecise as it is on computers, so be aware that you will get some variation (like 1.9999999 for 2.0). There is very little you can do to avoid this issue.
On 16/07/2013 at 00:28, xxxxxxxx wrote:
I have this:
GeData t_data; node->GetParameter(FOO_ID, t_data, DESCFLAGS_GET_0); LONG dataType = t_data.GetType();
In case of degrees, dataType will be DA_REAL
If there was a way to "detect degrees", if there had been a "DA_DEGREE", I could then, as you suggest, use the Deg(x) and Rad(s) to store, respectively read values, that gives nice looking results.
On 16/07/2013 at 10:49, xxxxxxxx wrote:
I can now "detect degrees", thanks to the help I got in the recent thread with the title "Getting Description information".