[Fwd: Re: purpose of s/double/Coord/ change in nr-types.h]
-----Forwarded Message----- From: MenTaLguY <mental@...3...> To: Peter Moulder <Peter.Moulder@...38...> Cc: Nathan Hurst <njh@...5...>, Inkscape ML <inkscape-devel@...142...ge.net> Subject: Re: purpose of s/double/Coord/ change in nr-types.h Date: Thu, 01 Jan 2004 15:47:01 -0500
On Thu, 2004-01-01 at 04:55, Peter Moulder wrote:
I believe that in revision 1.13 of src/libnr/nr-types.h you introduced a `typedef double Coord' (CVS comment "removed *S variants of NR structs").
Can you please document where Coord is to be used, or the purpose of this change?
Knowing the purpose of the type, or how the typedef may change in future, helps programmers to decide when to use Coord and when to use double.
The purpose of NR::Coord and NR::ICoord are to provide "real" and integer types used for storing coordinates in the rendering subsystem (and consequently having sufficient precision for that purpose).
(I'll add doxygen comments accordingly)
The motivating factor here was eliminating the entire class of bugs caused by switching between various precisions so much, particularly in the case of integer arithmetic.
If Coord and ICoord are used consistently for math involving coordinates (and have sufficient precision), we'll have many fewer headaches with precision issues.
I erred on the side of using Coord everywhere at first because I think it's less work to revert the few instances where it's not appropriate rather than the other way around.
Probably non-libnr code should have little reason to use them (operator*(double, NR::Point) should probably remain with the double, though maybe it should have an NR::Coord variant too).
I will let Nathan be the ultimate judge of where it's appropriate and where it's not, since the NR:: stuff is his purview at this point.
-mental
participants (1)
-
MenTaLguY