1 // Copyright (c) 1999
2 // Utrecht University (The Netherlands),
3 // ETH Zurich (Switzerland),
4 // INRIA Sophia-Antipolis (France),
5 // Max-Planck-Institute Saarbruecken (Germany),
6 // and Tel-Aviv University (Israel). All rights reserved.
7 //
8 // This file is part of CGAL (www.cgal.org)
9 //
10 // $URL: https://github.com/CGAL/cgal/blob/v5.3/Homogeneous_kernel/include/CGAL/Homogeneous/PointH3.h $
11 // $Id: PointH3.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot
12 // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
13 //
14 //
15 // Author(s) : Stefan Schirra
16
17 #ifndef CGAL_HOMOGENEOUS_POINT_3_H
18 #define CGAL_HOMOGENEOUS_POINT_3_H
19
20 #include <CGAL/Origin.h>
21 #include <boost/utility/enable_if.hpp>
22 #include <boost/mpl/and.hpp>
23 #include <boost/mpl/logical.hpp>
24
25 namespace CGAL {
26
27 template < class R_ >
28 class PointH3
29 {
30 typedef typename R_::RT RT;
31 typedef typename R_::FT FT;
32 typedef typename R_::Vector_3 Vector_3;
33 typedef typename R_::Point_3 Point_3;
34 typedef typename R_::Direction_3 Direction_3;
35 typedef typename R_::Aff_transformation_3 Aff_transformation_3;
36
37 typedef Rational_traits<FT> Rat_traits;
38
39 // Reference-counting is handled in Vector_3.
40 Vector_3 base;
41
42 public:
43
44 typedef typename Vector_3::Cartesian_const_iterator Cartesian_const_iterator;
45 typedef R_ R;
46
PointH3()47 PointH3() {}
48
PointH3(const Origin &)49 PointH3(const Origin &)
50 : base(NULL_VECTOR) {}
51
52 template < typename Tx, typename Ty, typename Tz >
53 PointH3(const Tx & x, const Ty & y, const Tz & z,
54 typename boost::enable_if< boost::mpl::and_< boost::mpl::and_< boost::is_convertible<Tx, RT>,
55 boost::is_convertible<Ty, RT> >,
56 boost::is_convertible<Tz, RT> > >::type* = 0)
base(x,y,z)57 : base(x, y, z) {}
58
PointH3(const FT & x,const FT & y,const FT & z)59 PointH3(const FT& x, const FT& y, const FT& z)
60 : base(x, y, z) {}
61
PointH3(const RT & x,const RT & y,const RT & z,const RT & w)62 PointH3(const RT& x, const RT& y, const RT& z, const RT& w)
63 : base(x, y, z, w) {}
64
65 FT x() const;
66 FT y() const;
67 FT z() const;
68 const RT & hx() const;
69 const RT & hy() const;
70 const RT & hz() const;
71 const RT & hw() const;
72 const RT & homogeneous(int i) const;
73 FT cartesian(int i) const;
74 FT operator[](int i) const;
75
76
cartesian_begin()77 Cartesian_const_iterator cartesian_begin() const
78 {
79 return base.cartesian_begin();
80 }
81
cartesian_end()82 Cartesian_const_iterator cartesian_end() const
83 {
84 return base.cartesian_end();
85 }
86
87 int dimension() const;
88
89 Direction_3 direction() const;
90 Point_3 transform( const Aff_transformation_3 & t) const;
91
92 bool operator==( const PointH3<R>& p) const;
93 bool operator!=( const PointH3<R>& p) const;
94 };
95
96
97 template < class R >
98 inline
99 const typename PointH3<R>::RT &
hx()100 PointH3<R>::hx() const
101 { return base.hx(); }
102
103 template < class R >
104 inline
105 const typename PointH3<R>::RT &
hy()106 PointH3<R>::hy() const
107 { return base.hy(); }
108
109 template < class R >
110 inline
111 const typename PointH3<R>::RT &
hz()112 PointH3<R>::hz() const
113 { return base.hz(); }
114
115 template < class R >
116 inline
117 const typename PointH3<R>::RT &
hw()118 PointH3<R>::hw() const
119 { return base.hw(); }
120
121 template < class R >
122 inline
123 typename PointH3<R>::FT
x()124 PointH3<R>::x() const
125 { return base.x(); }
126
127 template < class R >
128 inline
129 typename PointH3<R>::FT
y()130 PointH3<R>::y() const
131 { return base.y(); }
132
133 template < class R >
134 inline
135 typename PointH3<R>::FT
z()136 PointH3<R>::z() const
137 { return base.z(); }
138
139 template < class R >
140 inline
141 int
dimension()142 PointH3<R>::dimension() const
143 { return base.dimension(); }
144
145 template < class R >
146 inline
147 typename PointH3<R>::FT
cartesian(int i)148 PointH3<R>::cartesian(int i) const
149 {
150 return base.cartesian(i);
151 }
152
153 template < class R >
154 inline
155 const typename PointH3<R>::RT &
homogeneous(int i)156 PointH3<R>::homogeneous(int i) const
157 {
158 return base.homogeneous(i);
159 }
160
161 template < class R >
162 inline
163 typename PointH3<R>::FT
164 PointH3<R>::operator[](int i) const
165 {
166 return base[i];
167 }
168
169 template < class R >
170 inline
171 typename PointH3<R>::Direction_3
direction()172 PointH3<R>::direction() const
173 { return Direction_3(*this); }
174
175 template < class R >
176 inline
177 bool
178 PointH3<R>::operator==( const PointH3<R> & p) const
179 {
180 return base == p.base;
181 }
182
183 template < class R >
184 inline
185 bool
186 PointH3<R>::operator!=( const PointH3<R> & p) const
187 { return !(*this == p); }
188
189
190 template < class R >
191 inline
192 typename R::Point_3
transform(const typename PointH3<R>::Aff_transformation_3 & t)193 PointH3<R>::transform(const typename PointH3<R>::Aff_transformation_3& t) const
194 { return t.transform(static_cast<const Point_3&>(*this)); }
195
196 } //namespace CGAL
197
198 #endif // CGAL_HOMOGENEOUS_POINT_3_H
199