vgl_cylinder.h
Go to the documentation of this file.
1 // This is core/vgl/vgl_cylinder.h
2 #ifndef vgl_cylinder_h_
3 #define vgl_cylinder_h_
4 //:
5 // \file
6 // \brief defines a cylinder in 3D by a center point, radius, length and orientation
7 // \author Gamze D. Tunali (gamze@lems.brown.edu)
8 // \date Nov 07, 2005
9 //
10 // \verbatim
11 // Modifications
12 // Nov 2005 created
13 // \endverbatim
14 #include <iosfwd>
15 #include <vgl/vgl_point_3d.h>
16 #include <vgl/vgl_vector_3d.h>
17 #ifdef _MSC_VER
18 # include <vcl_msvc_warnings.h>
19 #endif
20 
21 template <class Type>
23 {
25  Type radius_;
26  Type length_;
28 
29  public:
30  //: Default constructor
31  vgl_cylinder(void): center_(0.0, 0.0, 0.0), radius_(0.0), length_(0.0) {}
32 
33  vgl_cylinder(const Type v[8])
34  :center_(v[0], v[1], v[2]), radius_(v[3]), length_(v[5]), orient_(vgl_vector_3d<Type> (v[6], v[7], v[8])) {}
35 
36  vgl_cylinder(Type cx, Type cy, Type cz, Type rad, Type len)
37  :center_(cx, cy, cz), radius_(rad), length_(len), orient_(vgl_vector_3d<Type> (0,0,1)) {}
38 
39  vgl_cylinder(vgl_point_3d<Type> cntr, Type rad, Type len)
40  :center_(cntr), radius_(rad), length_(len), orient_(vgl_vector_3d<Type> (0,0,1)) {}
41 
42  vgl_cylinder(vgl_point_3d<Type> cntr, Type rad, Type len, vgl_vector_3d<Type> orient)
43  :center_(cntr), radius_(rad), length_(len), orient_(orient) {}
44 
45  ~vgl_cylinder(void) = default;
46 
47  //: getters
48  vgl_point_3d<Type> center() const { return center_; }
49  Type radius() const { return radius_; }
50  Type length() const { return length_; }
52 
53  //: setters
54  void set_center(vgl_point_3d<Type> cntr) { center_ = cntr; }
55  void set_radius(Type rad) { radius_ = rad; }
56  void set_length(Type len) { length_ = len; }
57  void set_orientation (vgl_vector_3d<Type> orient) { orient_ = orient; }
58 
59  //: operations
60  bool operator==(vgl_cylinder<Type> const& cyl) const;
61 
62  //: Writes "<vgl_cylinder center=(x0,y0,z0), radius=r, length=l, direction=(x1,y1,z1)>" to stream
63  std::ostream& print(std::ostream& s) const;
64 };
65 
66 template <class T>
67 std::ostream& operator<<(std::ostream& os, const vgl_cylinder<T>& cyl);
68 
69 template <class T>
70 std::istream& operator>>(std::istream& s, vgl_cylinder<T>& cyl);
71 
72 #define VGL_CYLINDER_INSTANTIATE(T) extern "please include vgl/vgl_cylinder.hxx first"
73 
74 #endif // vgl_cylinder_h_
Type length() const
Definition: vgl_cylinder.h:50
vgl_cylinder(const Type v[8])
Definition: vgl_cylinder.h:33
void set_length(Type len)
Definition: vgl_cylinder.h:56
vgl_point_3d< Type > center_
Definition: vgl_cylinder.h:24
direction vector in Euclidean 3D space
bool operator==(vgl_cylinder< Type > const &cyl) const
operations.
Represents a cartesian 3D point.
Definition: vgl_fwd.h:11
vgl_cylinder(Type cx, Type cy, Type cz, Type rad, Type len)
Definition: vgl_cylinder.h:36
std::ostream & operator<<(std::ostream &s, vgl_orient_box_3d< Type > const &p)
Write box to stream.
void set_center(vgl_point_3d< Type > cntr)
setters.
Definition: vgl_cylinder.h:54
#define v
Definition: vgl_vector_2d.h:74
void set_radius(Type rad)
Definition: vgl_cylinder.h:55
vgl_cylinder(void)
Default constructor.
Definition: vgl_cylinder.h:31
a point in 3D nonhomogeneous space
Type radius() const
Definition: vgl_cylinder.h:49
vgl_vector_3d< Type > orientation() const
Definition: vgl_cylinder.h:51
~vgl_cylinder(void)=default
void set_orientation(vgl_vector_3d< Type > orient)
Definition: vgl_cylinder.h:57
vgl_point_3d< Type > center() const
getters.
Definition: vgl_cylinder.h:48
std::istream & operator>>(std::istream &is, vgl_orient_box_3d< Type > &p)
Read box from stream.
vgl_cylinder(vgl_point_3d< Type > cntr, Type rad, Type len)
Definition: vgl_cylinder.h:39
vgl_vector_3d< Type > orient_
Definition: vgl_cylinder.h:27
std::ostream & print(std::ostream &s) const
Writes "<vgl_cylinder center=(x0,y0,z0), radius=r, length=l, direction=(x1,y1,z1)>" to stream.
vgl_cylinder(vgl_point_3d< Type > cntr, Type rad, Type len, vgl_vector_3d< Type > orient)
Definition: vgl_cylinder.h:42