2 #ifndef vgl_point_3d_hxx_ 3 #define vgl_point_3d_hxx_ 18 # include <vcl_msvc_warnings.h> 24 : x_(p.x()/p.w()), y_(p.y()/p.w()), z_(p.z()/p.w())
38 set(p.x()/p.w(), p.y()/p.w(), p.z()/p.w());
55 Type r = ( (p1.
x()*p2.
y()-p1.
y()*p2.
x())*p3.
z()
56 +(p3.
x()*p1.
y()-p3.
y()*p1.
x())*p2.
z()
57 +(p2.
x()*p3.
y()-p2.
y()*p3.
x())*p1.
z()
58 +(p1.
x()*p4.
y()-p1.
y()*p4.
x())*p2.
z()
59 +(p4.
x()*p2.
y()-p4.
y()*p2.
x())*p1.
z()
60 +(p2.
x()*p1.
y()-p2.
y()*p1.
x())*p4.
z()
61 +(p3.
x()*p4.
y()-p3.
y()*p4.
x())*p1.
z()
62 +(p1.
x()*p3.
y()-p1.
y()*p3.
x())*p4.
z()
63 +(p4.
x()*p1.
y()-p4.
y()*p1.
x())*p3.
z()
64 +(p3.
x()*p2.
y()-p3.
y()*p2.
x())*p4.
z()
65 +(p2.
x()*p4.
y()-p2.
y()*p4.
x())*p3.
z()
66 +(p4.
x()*p3.
y()-p4.
y()*p3.
x())*p2.
z() );
75 double Num_x = (p1.
x()-p3.
x())*(p2.
x()-p4.
x());
76 double Num_y = (p1.
y()-p3.
y())*(p2.
y()-p4.
y());
77 double Num_z = (p1.
z()-p3.
z())*(p2.
z()-p4.
z());
78 double Den_x = (p1.
x()-p4.
x())*(p2.
x()-p3.
x());
79 double Den_y = (p1.
y()-p4.
y())*(p2.
y()-p3.
y());
80 double Den_z = (p1.
z()-p4.
z())*(p2.
z()-p3.
z());
81 if (Den_x == Den_y && Den_y == Den_z)
return (Num_x+Num_y+Num_z)/3/Den_x;
82 else return (Den_x*Num_x+Den_y*Num_y+Den_z*Num_z)/(Den_x*Den_x+Den_y*Den_y+Den_z*Den_z);
89 return s <<
"<vgl_point_3d "<< p.
x() <<
',' << p.
y() <<
',' << p.
z() <<
"> ";
100 if (! is.good())
return is;
110 if (is.eof())
return is;
111 if (is.peek() ==
'(') { is.ignore(); paren=
true; }
112 is >> std::ws >> tx >> std::ws;
113 if (is.eof())
return is;
114 if (is.peek() ==
',') is.ignore();
115 is >> std::ws >> ty >> std::ws;
116 if (is.eof())
return is;
117 if (is.peek() ==
',') is.ignore();
118 is >> std::ws >> tz >> std::ws;
120 if (is.eof())
return is;
121 if (is.peek() ==
')') is.ignore();
125 if (is.peek() ==
'>') is.ignore();
135 template <
class Type>
145 template <
class Type>
148 int n = (int)(
v.size());
152 Type cx = c.
x(), cy = c.
y(), cz = c.
z();
153 #define vgl_sqr(x) double((x)*(x)) 154 for (
int i=0; i<n; ++i)
161 #undef VGL_POINT_3D_INSTANTIATE 162 #define VGL_POINT_3D_INSTANTIATE(T) \ 163 template class vgl_point_3d<T >; \ 164 template double cross_ratio(vgl_point_3d<T >const&, vgl_point_3d<T >const&, \ 165 vgl_point_3d<T >const&, vgl_point_3d<T >const&); \ 166 template bool coplanar(vgl_point_3d<T > const&, vgl_point_3d<T > const&, \ 167 vgl_point_3d<T > const&, vgl_point_3d<T > const&); \ 168 template std::ostream& operator<<(std::ostream&, const vgl_point_3d<T >&); \ 169 template std::istream& operator>>(std::istream&, vgl_point_3d<T >&); \ 170 template double stddev(std::vector<vgl_point_3d<T > > const&) 172 #endif // vgl_point_3d_hxx_ bool operator==(const vgl_point_3d< Type > &p) const
Test for equality.
double stddev(std::vector< vgl_point_3d< Type > > const &v)
Return the "average deviation" of a set of given points from its centre of gravity.
homogeneous plane in 3D projective space
vgl_point_3d()=default
Default constructor.
point in projective 3D space
vgl_homg_point_1d< T > centre(vgl_homg_point_1d< T > const &p1, vgl_homg_point_1d< T > const &p2)
Return the point at the centre of gravity of two given points.
std::istream & read(std::istream &is)
Read from stream, possibly with formatting.
Represents a homogeneous 3D plane.
double cross_ratio(vgl_homg_point_1d< T >const &p1, vgl_homg_point_1d< T >const &p2, vgl_homg_point_1d< T >const &p3, vgl_homg_point_1d< T >const &p4)
cross ratio of four points.
Represents a cartesian 3D point.
std::ostream & operator<<(std::ostream &s, vgl_orient_box_3d< Type > const &p)
Write box to stream.
Represents a homogeneous 3D point.
a point in 3D nonhomogeneous space
Represents a Euclidean 3D plane.
T d() const
Return constant coefficient.
bool coplanar(l const &l1, l const &l2)
Are two lines coplanar, i.e., do they intersect?.
std::istream & operator>>(std::istream &is, vgl_orient_box_3d< Type > &p)
Read box from stream.
a plane in 3D nonhomogeneous space