ray3D.cpp

Go to the documentation of this file.
00001 
00015 #include <dlrGeometry/ray3D.h>
00016 #include <dlrNumeric/utilities.h>
00017 
00018 namespace dnum = dlr::numeric;
00019 
00020 namespace dlr {
00021 
00022   namespace geometry {
00023     
00024     // This constructor initializes the ray using a point and a
00025     // direction vector.
00026     Ray3D::
00027     Ray3D(const Vector3D& point,
00028           const Vector3D& direction,
00029           bool normalize)
00030       : m_origin(point),
00031         m_direction(direction)
00032     {
00033       if(normalize) {
00034         m_direction /= dnum::magnitude(m_direction);
00035       }
00036     }
00037 
00038     
00039     // The copy constructor deep copies its argument.
00040     Ray3D::
00041     Ray3D(const Ray3D& source)
00042       : m_origin(source.m_origin),
00043         m_direction(source.m_direction)
00044     {
00045       // Empty.
00046     }
00047 
00048 
00049     // The assignment operator deep copies its argument.
00050     Ray3D&
00051     Ray3D::
00052     operator=(const Ray3D& source)
00053     {
00054       if(&source != this) {
00055         m_origin = source.m_origin;
00056         m_direction = source.m_direction;
00057       }
00058       return *this;
00059     }
00060 
00061 
00062     /* ======= Non-member functions. ======= */
00063 
00064     std::ostream&
00065     operator<<(std::ostream& stream, const Ray3D& ray)
00066     {
00067       stream << "Ray3D{ "
00068              << ray.getOrigin() << ", "
00069              << ray.getDirectionVector() << " }";
00070       return stream;
00071     }
00072     
00073   } // namespace utilities
00074     
00075 } // namespace dlr

Generated on Mon Jul 9 20:34:03 2007 for dlrLibs Utility Libraries by  doxygen 1.5.2