// ====================================================================== // // 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_3.h // package : _3 // revision : $Revision$ // revision_date : $Date$ // author(s) : Andreas Fabri // Stefan Schirra // // coordinator : MPI, Saarbruecken () // ====================================================================== #ifndef CGAL_VECTOR_3_H #define CGAL_VECTOR_3_H #include #include #include CGAL_BEGIN_NAMESPACE template class Quotient; template class Vector_3 : public R_::Vector_3_base { public: typedef R_ R; typedef typename R::RT RT; typedef typename R::FT FT; typedef typename R::Point_3_base RPoint_3; typedef typename R::Vector_3_base RVector_3; friend CGAL_FRIEND_INLINE CGAL::Vector_3 point_to_vector_conversion CGAL_NULL_TMPL_ARGS (const CGAL::Point_3& p); Vector_3() {} Vector_3(const CGAL::Vector_3& v) : RVector_3( static_cast(v) ) {} Vector_3(const CGAL::Point_3& a, const CGAL::Point_3& b) : RVector_3( static_cast(a), static_cast(b) ) {} Vector_3(const RVector_3& v) : RVector_3(v) {} Vector_3(const Null_vector& v) : RVector_3(v) {} Vector_3(const RT& x, const RT& y, const RT& z) : RVector_3(x, y, z) {} Vector_3(const RT& x, const RT& y, const RT& z, const RT& w) : RVector_3(x, y, z, w) {} CGAL::Vector_3 operator+(const CGAL::Vector_3& w) const { return static_cast(*this) + static_cast(w); } CGAL::Vector_3 operator-(const CGAL::Vector_3& w) const { return static_cast(*this) - static_cast(w); } CGAL::Vector_3 operator-() const { return RVector_3::operator-(); } FT operator*(const CGAL::Vector_3& w) const { return static_cast(*this) * static_cast(w); } CGAL::Vector_3 operator*(const RT& c) const { return c * static_cast(*this) ; } CGAL::Vector_3 operator*(const Quotient& q) const { return (q.numerator() * static_cast(*this)) / q.denominator(); } CGAL::Vector_3 operator/(const Quotient& q) const { return (q.denominator() * static_cast(*this)) / q.numerator(); } CGAL::Vector_3 operator/(const RT& c) const { return static_cast(*this) / c; } CGAL::Direction_3 direction() const { return RVector_3::direction(); } CGAL::Vector_3 transform(const CGAL::Aff_transformation_3& t) const { return RVector_3::transform(t); } private: Vector_3(const CGAL::Point_3& p) : RVector_3(p) {} Vector_3(const CGAL::Direction_3& d) : RVector_3(d) {} }; template inline Vector_3 cross_product(const Vector_3& v, const Vector_3& w) { typedef typename R::Vector_3_base RVector_3; return cross_product(static_cast(v), static_cast(w)); } #ifndef CGAL_NO_OSTREAM_INSERT_VECTOR_3 template < class R > std::ostream& operator<<(std::ostream& os, const Vector_3& v) { typedef typename R::Vector_3_base RVector_3; return os << static_cast(v); } #endif // CGAL_NO_OSTREAM_INSERT_VECTOR_3 #ifndef CGAL_NO_ISTREAM_EXTRACT_VECTOR_3 template < class R > std::istream& operator>>(std::istream& is, Vector_3& p) { typedef typename R::Vector_3_base RVector_3; return is >> static_cast(p); } #endif // CGAL_NO_ISTREAM_EXTRACT_VECTOR_3 CGAL_END_NAMESPACE #endif // CGAL_VECTOR_3_H