plane3D.cpp

Go to the documentation of this file.
00001 
00015 #include <dlrGeometry/plane3D.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 plane using three points.
00025     Plane3D::
00026     Plane3D(const Vector3D& point0,
00027             const Vector3D& point1,
00028             const Vector3D& point2,
00029             bool orthonormalize)
00030       : m_origin(point0),
00031         m_directionVector0(point1 - point0),
00032         m_directionVector1(point2 - point0)
00033     {
00034       if(orthonormalize) {
00035         m_directionVector0 /= dnum::magnitude(m_directionVector0);
00036         m_directionVector1 -=
00037           (dnum::dot(m_directionVector1, m_directionVector0)
00038            * m_directionVector0);
00039         m_directionVector1 /= dnum::magnitude(m_directionVector1);
00040       }
00041     }
00042 
00043     
00044     // The copy constructor deep copies its argument.
00045     Plane3D::
00046     Plane3D(const Plane3D& source)
00047       : m_origin(source.m_origin),
00048         m_directionVector0(source.m_directionVector0),
00049         m_directionVector1(source.m_directionVector1)
00050     {
00051       // Empty.
00052     }
00053 
00054 
00055     // The assignment operator deep copies its argument.
00056     Plane3D&
00057     Plane3D::
00058     operator=(const Plane3D& source)
00059     {
00060       if(&source != this) {
00061         m_origin = source.m_origin;
00062         m_directionVector0 = source.m_directionVector0;
00063         m_directionVector1 = source.m_directionVector1;
00064       }
00065       return *this;
00066     }
00067 
00068 
00069     /* ======= Non-member functions. ======= */
00070 
00071     std::ostream&
00072     operator<<(std::ostream& stream, const Plane3D& plane)
00073     {
00074       stream << "Plane3D{ "
00075              << plane.getOrigin() << ", "
00076              << plane.getDirectionVector0() << ", "
00077              << plane.getDirectionVector1() << " }";
00078       return stream;
00079     }
00080 
00081 
00082   } // namespace utilities
00083     
00084 } // namespace dlr

Generated on Wed Nov 25 11:45:25 2009 for dlrGeometry Utility Library by  doxygen 1.5.8