// ====================================================================== // // Copyright (c) 1999 The CGAL Consortium // // This software and related documentation is part of an INTERNAL release // of the Computational Geometry Algorithms Library (CGAL). It is not // intended for general use. // // ---------------------------------------------------------------------- // // release : // release_date : // // file : Vector_2.h // package : _2 // revision : $Revision$ // revision_date : $Date$ // author(s) : Andreas Fabri // Stefan Schirra // // coordinator : MPI, Saarbruecken () // ====================================================================== #ifndef CGAL_VECTOR_2_H #define CGAL_VECTOR_2_H #include #include CGAL_BEGIN_NAMESPACE class Null_vector; template class Quotient; template class Vector_2 : public R_::Vector_2_base { public: typedef R_ R; typedef typename R::RT RT; typedef typename R::FT FT; typedef typename R::Point_2_base RPoint_2; typedef typename R::Vector_2_base RVector_2; friend CGAL_FRIEND_INLINE CGAL::Vector_2 CGAL_SCOPE point_to_vector_conversion CGAL_NULL_TMPL_ARGS (const CGAL::Point_2 &p); Vector_2() {} Vector_2(const CGAL::Vector_2 &v) : RVector_2(static_cast(v)) {} Vector_2(const CGAL::Point_2& a, const CGAL::Point_2& b) : RVector_2(static_cast(a), static_cast(b) ) {} Vector_2(const RVector_2& v) : RVector_2(v) {} Vector_2(const Null_vector &v) : RVector_2(v) {} Vector_2(const RT &x, const RT &y) : RVector_2(x,y) {} Vector_2(const RT &x, const RT &y, const RT &w) : RVector_2(x,y,w) {} CGAL::Vector_2 operator+(const CGAL::Vector_2 &w) const { return static_cast(*this) + static_cast(w); } CGAL::Vector_2 operator-(const CGAL::Vector_2 &w) const { return static_cast(*this) - static_cast(w); } CGAL::Vector_2 operator-() const { return RVector_2::operator-(); } FT operator*(const CGAL::Vector_2 &w) const { return static_cast(*this) * static_cast(w); } CGAL::Vector_2 operator*(const RT &c) const { return c * static_cast(*this); } CGAL::Vector_2 operator*(const Quotient &q) const { return (q.numerator() * static_cast(*this)) / q.denominator(); } CGAL::Vector_2 operator/(const Quotient &q) const { return (q.denominator() * static_cast(*this)) / q.numerator(); } CGAL::Vector_2 operator/(const RT &c) const { return static_cast(*this) / c; } CGAL::Direction_2 direction() const { return RVector_2::direction(); } CGAL::Vector_2 perpendicular(const Orientation &o) const { return RVector_2::perpendicular(o); } CGAL::Vector_2 transform(const CGAL::Aff_transformation_2 &t) const { return RVector_2::transform(t); } private: Vector_2(const CGAL::Point_2 &p) : RVector_2(p) {} Vector_2(const CGAL::Direction_2 &d) : RVector_2(d) {} }; #ifndef CGAL_NO_OSTREAM_INSERT_VECTOR_2 template < class R > std::ostream & operator<<(std::ostream &os, const Vector_2 &v) { typedef typename R::Vector_2_base RVector_2; return os << static_cast(v); } #endif // CGAL_NO_OSTREAM_INSERT_VECTOR_2 #ifndef CGAL_NO_ISTREAM_EXTRACT_VECTOR_2 template < class R > std::istream & operator>>(std::istream &is, Vector_2 &p) { typedef typename R::Vector_2_base RVector_2; return is >> static_cast(p); } #endif // CGAL_NO_ISTREAM_EXTRACT_VECTOR_2 CGAL_END_NAMESPACE #endif // CGAL_VECTOR_2_H