#ifndef PLine2d_HH #define PLine2d_HH /////////////////////////////////////////////////////////////////////// //! file="amma/Geometry/PrGeo2/PLine2d.hh" //! lib=Mpg2 //! userlevel=Normal //! author="Radek Marik" //! date="26.05.1995" //! docentry="Geometry.Projective.2-D" //! rcsid="$Id: PLine2d.hh,v 1.6 1998/09/22 11:20:29 ees1cg Exp $" #include "amma/Boolean.hh" #include "amma/PPtLi2d.hh" class ostream; class istream; class Point2dC; class Vector2dC; class Line2dPVC; class Line2dPPC; class PPoint2dC; // -------------------------------------------------------------------- // ******** PLine2dC ************************************************* // -------------------------------------------------------------------- //: Plane in 3D projective space // The class represents a line in 2 dimensional projective space. // A line contains 3 real numbers which serve as its projective // coordinates. class PLine2dC: public PPointLine2dC { public: // Type definitions. // ----------------- typedef PPointLine2dC::PCoordT PCoordT; // A projective coordinate. typedef PPointLine2dC::CCoordT CCoordT; // An cartesian coordinate. public: // Constructors, assigment, copy, and destructor. // ---------------------------------------------- inline PLine2dC(); // Constructs the line whose coordinates are zeros, eg. non-existing // projective line. inline PLine2dC(const Vector2dC & n, RealT d); // Constructs the projective line equivalent to the Euiclidian // line determined by the equation n.X()*x + n.Y()*y + d = 0. inline PLine2dC(const Point2dC & p1, const Point2dC & p2); // Constructs the projective line passing through two Euclidian // points p1, p2. inline PLine2dC(const Point2dC & p, const Vector2dC & v); // Constructs the projective line passing through the Euclidian // point 'p' and the Euclidian line direction vector 'v'. PLine2dC(const Line2dPVC & l); // Constructs the projective line from the Euclidian line 'l'. PLine2dC(const Line2dPPC & l); // Constructs the projective line from the Euclidian line 'l'. inline PLine2dC(PCoordT p1, PCoordT p2, PCoordT p3); // Constructs the line (p1, p2, p3). inline PLine2dC(const PPointLine2dC & p0, const PPointLine2dC & p1); // Constructs the line passing through two projective points 'p0' and // 'p1'. inline PLine2dC(const PPointLine2dC & p); // Constructs the line from the point/line object 'p'. inline PLine2dC(const PLine2dC & p); // Copy constructor. inline const PLine2dC & operator=(const PLine2dC & p); // Assigment of point. // Access to the object. // --------------------- Vector2dC Normal() const; // Returns the normal of a corresponding Euclidian line. If this // projective line is ideal the function returns the zero vector. inline const PLine2dC & PLine2d() const; // Access to this constant object. inline PLine2dC & PLine2d(); // Access to the point. // Logical conditions. // ------------------- inline BooleanT IsIdeal() const; // Returns TRUE iff this line is an ideal projective line. // The line is an ideal projective line if the absolute value of // the ratio Scale()/SumAbs() is smaller or equal to // the threshold 'Point3dC::relZero'. // Arithmetical operations. // ------------------------ inline const PLine2dC & operator*=(const RealT alpha); // Multiplies all coordinates by 'alpha'. inline const PLine2dC & operator/=(const RealT alpha); // Divides all coordinates by 'alpha'. inline PLine2dC operator*(const RealT alpha) const; // Returns the line which coordinates are multiplied by 'alpha'. inline PLine2dC operator/(const RealT alpha) const; // Returns the line which coordinates are divided by 'alpha'. // Geometrical constructions. // -------------------------- PPoint2dC Intersection(const PLine2dC & l) const; // Returns the projective point that is the intersection of both lines. friend inline PLine2dC operator*(RealT lambda, const PLine2dC & p); friend inline PLine2dC operator/(RealT lambda, const PLine2dC & p); friend istream & operator>>(istream & inS, PLine2dC & point); }; inline PLine2dC operator*(RealT lambda, const PLine2dC & l); // Returns the line which is the 'lambda' multiplication of 'l'. inline PLine2dC operator/(RealT lambda, const PLine2dC & p); // Returns the line which coordinates are the 'lambda' divided by the // corresponding coordinate of 'l'. ostream & operator<<(ostream & outS, const PLine2dC & l); // Writes the projective line 'l' into the output stream. istream & operator>>(istream & inS, PLine2dC & l); // Reads the projective line parameters from the input stream. // ------------------------------------------------------------------- // ******** PLine2dC ************************************************ // ------------------------------------------------------------------- #include "amma/Vector2d.hh" inline PLine2dC::PLine2dC() //================== : PPointLine2dC(0,0,0) {} inline PLine2dC::PLine2dC(const Vector2dC & n, RealT d) //========================================================= : PPointLine2dC(n.X(), n.Y(), d) {} inline PLine2dC::PLine2dC(const Point2dC & p0, const Point2dC & p1) //============================================================ : PPointLine2dC(p0, p1) {} inline PLine2dC::PLine2dC(const Point2dC & p, const Vector2dC & v) //========================================================== : PPointLine2dC(p, v) {} inline PLine2dC::PLine2dC(PLine2dC::PCoordT p1, PLine2dC::PCoordT p2, PLine2dC::PCoordT p3) //====================================== : PPointLine2dC(p1, p2, p3) {} inline PLine2dC::PLine2dC(const PLine2dC & p) //==================================== : PPointLine2dC(p) {} inline PLine2dC::PLine2dC(const PPointLine2dC & p) //========================================= : PPointLine2dC(p) {} inline PLine2dC::PLine2dC(const PPointLine2dC & p0, const PPointLine2dC & p1) //==================================================================== : PPointLine2dC(p0, p1) {} inline const PLine2dC & PLine2dC::operator=(const PLine2dC & p) //===================================== { PPointLine2dC::operator=(p); return *this; } inline BooleanT PLine2dC::IsIdeal() const //======================= { return IsIdealLine(); } inline const PLine2dC & PLine2dC::PLine2d() const //======================= { return *this; } inline PLine2dC & PLine2dC::PLine2d() //================= { return *this; } inline const PLine2dC & PLine2dC::operator*=(const RealT alpha) //=============================================== { PPointLine2dC::operator*=(alpha); return *this; } inline const PLine2dC & PLine2dC::operator/=(const RealT alpha) //=============================================== { PPointLine2dC::operator/=(alpha); return *this; } inline PLine2dC PLine2dC::operator*(const RealT alpha) const //==================================================== { return PPointLine2dC::operator*(alpha); } inline PLine2dC PLine2dC::operator/(const RealT alpha) const //==================================================== { return PPointLine2dC::operator/(alpha); } inline PLine2dC operator*(RealT lambda, const PLine2dC & p) //=================================================== { return p * lambda; } inline PLine2dC operator/(RealT lambda, const PLine2dC & p) //=================================================== { return ::operator/(lambda, (PPointLine2dC) p ); } #endif // IAPS - Image analysis program system. // End of include file PLine2d.hh