Rev 65013 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
DIVISION BY ZERO in grid units:- There are two main conversion scenarios in grid:+ converting a unit to a final location/dimension for drawing(or for determining the boundary of a drawn object)- The grid graphics package converts all incoming units to INCHES(then uses R graphics engine to convert to device coordinates)- Almost all conversions to INCHES involve multiplication only- The exception is "native" units, which require a division bythe range of the native scale. This creates the possibilityof division by zero if the range of the native scale is zero(i.e., the scale limits are identical).SOLUTION: make it an error to set a scale with identical limits.+ converting from one unit to another (within a viewport context)- Conversions, via convertUnit(), involve two steps:conversion from the original unit TO inches and thenconversion FROM inches to the final unit.- Any division-by-zero in the conversion TO inches is avoidedby the solution above.- Division-by-zero in the conversion FROM inches can occurIF the viewport has zero physical width or heightAND the final unit is relative ("npc" or "native").SOLUTION: (i) IF original unit is also relative ...(a) IF original unit is plain unit AND we are NOTconverting 'x' to 'y' (or vice versa) catch thisas special case and make it work.(b) OTHERWISE (original unit is complex or we areconverting 'x' to 'y' or vice versa)return zero.(ii) IF original unit is absolute, throw an error(because the conversion does not make sense) UNLESS the originalunit value is zero, in which case return zero.- NOTE that conversion FROM anything TO an absolute final unitdoes not risk division-by-zero, even when viewport has zerophysical width or height. (The result is either zero, ifthe original unit is relative, or an identity operation [interms of the physical result] if the original unit is absolute.)