Bayeux  3.4.1
Core Foundation library for SuperNEMO
ellipse.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-02-14
4  * Last modified: 2015-02-15
5  *
6  * License:
7  *
8  * Description:
9  *
10  * A elliptic arc in x-y plane
11  *
12  * History:
13  *
14  */
15 
16 #ifndef GEOMTOOLS_ELLIPSE_H
17 #define GEOMTOOLS_ELLIPSE_H 1
18 
19 // Standard library:
20 #include <iostream>
21 #include <string>
22 
23 // This project:
24 #include <geomtools/i_shape_1d.h>
27 
28 namespace geomtools {
29 
31  class ellipse : public i_shape_1d,
33  {
34 
35  public:
36 
38  static const std::string & ellipse_label();
39 
41  bool is_valid() const;
42 
44  double get_x_radius() const;
45 
47  double get_y_radius() const;
48 
50  void set_radii(double x_radius_, double y_radius_);
51 
53  void set_x_radius(double x_radius_);
54 
56  void set_y_radius(double y_radius_);
57 
59  const angular_range & get_angle_domain() const;
60 
62  bool has_partial_angle() const;
63 
65  bool has_start_angle() const;
66 
68  void set_start_angle(double);
69 
71  double get_start_angle() const;
72 
74  bool has_delta_angle() const;
75 
77  void set_delta_angle(double);
78 
80  double get_delta_angle() const;
81 
83  double get_circumference() const;
84 
86  virtual unsigned int get_number_of_path() const;
87 
89  virtual double get_length(uint32_t flags_ = PATH_ALL_BITS) const;
90 
92  bool is_x_oriented() const;
93 
95  bool is_y_oriented() const;
96 
98  bool is_circle() const;
99 
101  double get_excentricity() const;
102 
104  double get_focal_to_center() const;
105 
107  ellipse();
108 
110  ellipse(double x_radius_, double y_radius_);
111 
113  ellipse(double x_radius_, double y_radius_, double start_angle_, double delta_angle_);
114 
116  void compute_x_y_from_theta(double theta_, double & x_, double & y_) const;
117 
119  void compute_theta_from_x(double x_, double & theta_) const;
120 
126  static void squared_distance_to_point_with_derivative(double t_,
127  void * params_,
128  double * f_,
129  double * df_);
130 
134  static double squared_distance_to_point(double t_,
135  void * params_);
136 
137 
141  double compute_squared_distance_to_point(double t_, double xm_, double ym_) const;
142 
143  // /// Compute the orthogonal projection of a point on the elliptical arc
144  // bool compute_orthogonal_projection(const vector_3d & a_position,
145  // vector_3d & a_projection,
146  // double a_tolerance) const;
147 
149  virtual ~ellipse();
150 
152  virtual std::string get_shape_name() const;
153 
155  virtual void tree_dump(std::ostream & a_out = std::clog,
156  const std::string & a_title = "",
157  const std::string & a_indent = "",
158  bool a_inherit= false) const;
159 
161  virtual bool is_on_curve(const vector_3d &,
162  double a_tolerance = GEOMTOOLS_PROPER_TOLERANCE) const;
163 
165  virtual vector_3d get_direction_on_curve(const vector_3d & a_tposition) const;
166 
168  virtual void generate_wires_self(wires_type & wires_,
169  uint32_t options_ = 0) const;
170 
172  void initialize(const datatools::properties &, const handle_dict_type * = 0);
173 
175  virtual void reset();
176 
177  protected:
178 
180  void _set_defaults();
181 
182  private:
183 
184  double _x_radius_;
185  double _y_radius_;
186  angular_range _angle_domain_;
187 
188  // Registration interface :
190 
191  };
192 
193 } // end of namespace geomtools
194 
195 #endif // GEOMTOOLS_ELLIPSE_H
196 
197 /*
198 ** Local Variables: --
199 ** mode: c++ --
200 ** c-file-style: "gnu" --
201 ** tab-width: 2 --
202 ** End: --
203 */
The abstract base class for all 1D curves/shapes.
Definition: i_shape_1d.h:32
bool is_valid() const
Check the validity of the ellipse.
void set_delta_angle(double)
Set the delta angle.
void initialize(const datatools::properties &, const handle_dict_type *=0)
Initialize from properties and a dictionary of 3D-objects.
void set_x_radius(double x_radius_)
Set the X radius.
Definition: utils.h:184
bool is_x_oriented() const
Check if the ellipse is X oriented.
virtual void tree_dump(std::ostream &a_out=std::clog, const std::string &a_title="", const std::string &a_indent="", bool a_inherit=false) const
Smart print.
double get_excentricity() const
Return the excentricity.
bool has_start_angle() const
Check the start angle.
virtual bool is_on_curve(const vector_3d &, double a_tolerance=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a point is on the curve (approximative algorithm)
double compute_squared_distance_to_point(double t_, double xm_, double ym_) const
static double squared_distance_to_point(double t_, void *params_)
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
bool has_partial_angle() const
Check for the partial arc.
virtual double get_length(uint32_t flags_=PATH_ALL_BITS) const
Return the length of the target paths.
void _set_defaults()
Set default attributes values.
void compute_x_y_from_theta(double theta_, double &x_, double &y_) const
Compute the X and Y coordinates of the point on the ellipse with angle theta.
static void squared_distance_to_point_with_derivative(double t_, void *params_, double *f_, double *df_)
static const std::string & ellipse_label()
Return the label of 1D shape.
void set_y_radius(double y_radius_)
Set the Y radius.
void set_start_angle(double)
Set the start angle.
double get_circumference() const
Return the circumference.
std::map< std::string, object_entry > handle_dict_type
Dictionary of handle of 3D object entries.
Definition: i_object_3d.h:124
double get_start_angle() const
Return the start angle.
Angular range.
Definition: angular_range.h:33
A circular arc (1D shape)
Definition: ellipse.h:31
const angular_range & get_angle_domain() const
Return the angle domain.
virtual ~ellipse()
Destructor.
virtual std::string get_shape_name() const
Return the name of this solid shape class.
virtual vector_3d get_direction_on_curve(const vector_3d &a_tposition) const
Returns the direction of a point on the curve.
#define GEOMTOOLS_OBJECT_3D_REGISTRATION_INTERFACE(ModelClassName)
Definition: i_object_3d.h:260
brief Abstract interface for objects that can describe themselves as a collection of polylines for 3D...
Definition: i_wires_3d_rendering.h:39
virtual void reset()
Reset.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
double get_focal_to_center() const
Return the distance between the focal and the center.
virtual void generate_wires_self(wires_type &wires_, uint32_t options_=0) const
Generate a sequence of polylines for wires 3D rendering.
bool is_circle() const
Check if the ellipse is a circle.
void compute_theta_from_x(double x_, double &theta_) const
Compute the theta angle of the point on the ellipse with X coordinate.
ellipse()
Default constructor.
double get_x_radius() const
Return the X radius.
bool is_y_oriented() const
Check if the ellipse is Y oriented.
void set_radii(double x_radius_, double y_radius_)
Set the radii.
double get_y_radius() const
Return the Y radius.
std::list< polyline_type > wires_type
Alias for a list of 3D-polylines.
Definition: utils.h:61
bool has_delta_angle() const
Check the dedislta angle.
virtual unsigned int get_number_of_path() const
Return the number of path.
double get_delta_angle() const
Return the delta angle.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125