|
Boost : |
Subject: Re: [boost] Geometry and spatial indexes, my opinion
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2008-10-09 14:06:45
>> In VLSI layout we sometimes represent the layer as the z axis of a 3D
>> coordinate system. Because there are only tens of layers we can use
>> something smaller than int to store it. However, the compiler will
>> often pad it back to word aligned addressing and insert padding bytes
>> into a data structure, reducing the memory savings. Also,
internally,
>> all arithmetic is 32 bit or greater, so there is no advantage in
using
>> smaller data types for local operations. I think it is perfectly
>> reasonable to allow point classes to have heterogeneous coordinate
>> types, but require them to cast to and from a homogeneous coordinate
>> type at the interface between that object and the geometry library.
In
>> all three examples, we would make the coordinate type of the
interface
>> between the point and the library int and allow the 16 bit value to
cast
>> up to 32 bits when it is read into an algorithm and back down to 16
bits
>> when it is written out.
--Michael Fawcett wrote:
>I don't understand why the interface or algorithm cares whether it's
>homogeneous or heterogeneous.
The interface or the algorithm must necessarily be much more complex to
accommodate heterogeneous coordinates. Moreover, you have a real
problem with casting when you do arithmetic between heterogeneous
coordinates in an algorithm.
x_coordinate_type x;
y_coordinate_type y;
?_coordinate_type result = x+y;
You would probably have to register a type for casting to:
x_coordinate_type x;
y_coordinate_type y;
general_coordinate_type result = (general_coordinate_type)x +
(general_coordinate_type)y;
Which is exactly what you do if you cast to the general coordinate type
in the interface between the algorithm and the data type.
Luke
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk