#include <amanatidesWoo2D.h>
Public Types | |
typedef AmanatidesWoo2DIterator < ARRAY2D > | iterator |
This typedef specifies the type which will be returned by member functions begin() and end(). | |
Public Member Functions | |
AmanatidesWoo2D (ARRAY2D &data, const Transform2D &pixelTworld, const Vector2D &rayOrigin, const Vector2D &rayDirection, bool downstreamOnly=true) | |
This constructor specifies all of the internal state of the AmanatidesWoo2D class. | |
AmanatidesWoo2D (const AmanatidesWoo2D &source) | |
This is the copy constructor. | |
~AmanatidesWoo2D () | |
This is the destructor. | |
iterator | begin () |
This member function returns an iterator which references the first pixel along the traced ray. | |
iterator | end () |
This member function returns an iterator which references an invalid pixel, and which will be equal (==) to the iterator returned by member function begin() when that iterator has fully traversed the line of pixels. | |
ARRAY2D & | getData () |
This member function returns a reference to the array object over which iteration is performed. | |
bool | validIntersection () |
This member function returns true if the iterator returned by member function begin() will point to a valid pixel. | |
AmanatidesWoo2D & | operator= (const AmanatidesWoo2D &source) |
The assignment operator copies its argument. |
The algorithm is for efficient ray tracing through regular grids. For convenience, there are two coordinate systems associated with this class:
The pixel coordinate system has its origin at the corner of the 2D array, has its first coordinate (which we'll call U) parallel to the rows of the array, and has its second coordinate (which we'll call V) parallel to the columns of the array. As you move along any row of the 2D array, the transition from the first column to the second occurs at U == 1.0, the transition from the second column to the third occurs at U == 2.0, and so on. Similarly as you move along any column of the array, the transition from the first row to the second occurs at V == 1.0, and the transition from the second row to the third occurs at V == 2.0.
Once constructed, you can use the AmanatidesWoo2D class to access pixels along a straight line through the 2D array using STL-style iteration. That is, the member functions AmanatidesWoo2D::begin() returns an iterator which references subsequent pixels along the line, and will become equal (==) to the iterator returned by AmanatidesWoo2D::end() when the line passes out of the 2D array. Here's an example usage, which will probably format terribly in the Doxygen-generated doc:
typedef AmanatidesWoo2D< Array2D<int> >iterator awIterator;
AmanatidesWoo2D< Array2D<int> > rayTracer( myArray2D, rayOrigin, rayDirection, false);
awIterator iterator0 = rayTracer.begin();
awIterator iterator1 = rayTracer.end();
for(; iterator0 != iterator1; ++iterator0) {
*iterator0 = 0;
}
Definition at line 80 of file amanatidesWoo2D.h.
typedef AmanatidesWoo2DIterator<ARRAY2D> dlr::numeric::AmanatidesWoo2D< ARRAY2D >::iterator |
This typedef specifies the type which will be returned by member functions begin() and end().
AmanatidesWoo2DIterator is a forward iterator, and has unusual semantics for operator==(). Be sure to understand them before using this class.
Definition at line 91 of file amanatidesWoo2D.h.
dlr::numeric::AmanatidesWoo2D< ARRAY2D >::AmanatidesWoo2D | ( | ARRAY2D & | data, | |
const Transform2D & | pixelTworld, | |||
const Vector2D & | rayOrigin, | |||
const Vector2D & | rayDirection, | |||
bool | downstreamOnly = true | |||
) | [inline] |
This constructor specifies all of the internal state of the AmanatidesWoo2D class.
After construction, the AmanatidesWoo2D instance is ready to be used.
data | This argument specifies the 2D array over which to iterate. | |
pixelTworld | This parameter specifies a coordinate transformation which takes world coordinates and converts them into pixel coordinates. | |
rayOrigin | This parameter specifies the starting point of the ray to be traced, expressed in world coordinates. If you'd rather express rayOrigin and rayDirection in pixel coordinates, simply set argument pixelTworld to the identity transform. Note that rayOrigin does not have to lie inside the pixel array. | |
rayDirection | This parameter specifies the direction of the ray to be traced, expressed in world coordinates. In other words, any point on the line of interest can be written as (rayOrigin + t * rayDirection) for some value of t. If you'd rather express rayOrigin and rayDirection in pixel coordinates, simply set argument pixelTworld to the identity transform. | |
downstreamOnly | This boolean argument specifies whether pixels "upstream" of rayOrigin are to be included in the pixel traversal. If downstreamOnly is set to false, pixels which intersect the line (rayOrigin + t * rayDirection) will be included in the iteration even if they intersect the line at negative values of t. |
Definition at line 344 of file amanatidesWoo2D.h.
References dlr::numeric::Vector2D::x(), and dlr::numeric::Vector2D::y().
dlr::numeric::AmanatidesWoo2D< ARRAY2D >::AmanatidesWoo2D | ( | const AmanatidesWoo2D< ARRAY2D > & | source | ) | [inline] |
This is the copy constructor.
After copying, the new AmanatidesWoo2D instance and the copied instance both reference the same pixel array.
source | The AmanatidesWoo2D instance to be copied. |
Definition at line 477 of file amanatidesWoo2D.h.
dlr::numeric::AmanatidesWoo2D< ARRAY2D >::~AmanatidesWoo2D | ( | ) | [inline] |
This is the destructor.
It destroys the AmanatidesWoo2D instance and cleans up any allocated memory.
Definition at line 495 of file amanatidesWoo2D.h.
AmanatidesWoo2D< ARRAY2D >::iterator dlr::numeric::AmanatidesWoo2D< ARRAY2D >::begin | ( | ) | [inline] |
This member function returns an iterator which references the first pixel along the traced ray.
If constructor argument downstreamOnly was set to false, this iterator will either point to a pixel on the very edge of the array, or (in the case that the ray does not intersect the pixel array) be equal to this->end(). If constructor argument downstreamOnly was set to true, then this iterator will point to an edge pixel, or point to an interior pixel (in the case that rayOrigin lies within the boundaries of the pixel array), or be equal to this->end() (in the case that the ray does not intersect the pixel array, and in the case that rayOrigin lies outside the pixel array and rayDirection points away from the pixel array).
Definition at line 500 of file amanatidesWoo2D.h.
AmanatidesWoo2D< ARRAY2D >::iterator dlr::numeric::AmanatidesWoo2D< ARRAY2D >::end | ( | ) | [inline] |
This member function returns an iterator which references an invalid pixel, and which will be equal (==) to the iterator returned by member function begin() when that iterator has fully traversed the line of pixels.
Definition at line 510 of file amanatidesWoo2D.h.
ARRAY2D& dlr::numeric::AmanatidesWoo2D< ARRAY2D >::getData | ( | ) | [inline] |
This member function returns a reference to the array object over which iteration is performed.
Definition at line 196 of file amanatidesWoo2D.h.
AmanatidesWoo2D< ARRAY2D > & dlr::numeric::AmanatidesWoo2D< ARRAY2D >::operator= | ( | const AmanatidesWoo2D< ARRAY2D > & | source | ) | [inline] |
The assignment operator copies its argument.
After copying, *this and the copied instance both reference the same pixel array.
source | The AmanatidesWoo2D instance to be copied. |
Definition at line 532 of file amanatidesWoo2D.h.
References dlr::numeric::AmanatidesWoo2D< ARRAY2D >::m_data, dlr::numeric::AmanatidesWoo2D< ARRAY2D >::m_initialU, dlr::numeric::AmanatidesWoo2D< ARRAY2D >::m_initialV, dlr::numeric::AmanatidesWoo2D< ARRAY2D >::m_stepU, dlr::numeric::AmanatidesWoo2D< ARRAY2D >::m_stepV, dlr::numeric::AmanatidesWoo2D< ARRAY2D >::m_tDeltaU, dlr::numeric::AmanatidesWoo2D< ARRAY2D >::m_tDeltaV, dlr::numeric::AmanatidesWoo2D< ARRAY2D >::m_tMaxU, dlr::numeric::AmanatidesWoo2D< ARRAY2D >::m_tMaxV, dlr::numeric::AmanatidesWoo2D< ARRAY2D >::m_tStart, and dlr::numeric::AmanatidesWoo2D< ARRAY2D >::m_validIntersection.
bool dlr::numeric::AmanatidesWoo2D< ARRAY2D >::validIntersection | ( | ) | [inline] |
This member function returns true if the iterator returned by member function begin() will point to a valid pixel.
In other words, if constructor argument downstreamOnly was set to false, the return value of validIntersection() indicates whether the ray specified in the constructor actually intersects the pixel array. If constructor argument downstreamOnly was set to true, the return value of validIntersection whether the "downstream" half of the ray actually intersects the pixel array.
Definition at line 524 of file amanatidesWoo2D.h.