opennurbs_ellipse.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(OPENNURBS_ELLIPSE_INC_)
18 #define OPENNURBS_ELLIPSE_INC_
19 
20 class ON_Ellipse;
21 class ON_Plane;
22 
23 class ON_CLASS ON_Ellipse
24 {
25 public:
26  ON_Ellipse(); // zeros all fields - plane is invalid
27 
28  ON_Ellipse(
29  const ON_Plane&,
30  double, double // radii for x and y vectors
31  );
32 
33  ON_Ellipse(
34  const ON_Circle&
35  );
36 
37  ~ON_Ellipse();
38 
39  ON_Ellipse& operator=(const ON_Circle&);
40 
41  bool Create(
42  const ON_Plane&, // point on the plane
43  double, double // radii for x and y vectors
44  );
45 
46  bool Create(
47  const ON_Circle&
48  );
49 
50  bool IsValid() const; // returns true if all fields contain reasonable
51  // information and equation jibes with point and Z.
52 
53  bool IsCircle() const; // returns true is ellipse is a circle
54 
55  double Radius(
56  int // 0 = x axis radius, 1 = y axis radius
57  ) const;
58  const ON_3dPoint& Center() const;
59  const ON_3dVector& Normal() const;
60  const ON_Plane& Plane() const; // plane containing ellipse
61 
62  /*
63  Returns:
64  Distance from the center to a focus, commonly called "c".
65  */
66  double FocalDistance() const;
67 
68  bool GetFoci( ON_3dPoint& F1, ON_3dPoint& F2 ) const;
69 
70  // Evaluation uses the trigonometrix parameterization
71  // t -> plane.origin + cos(t)*radius[0]*plane.xaxis + sin(t)*radius[1]*plane.yaxis
72  // evaluate parameters and return point
73  ON_3dPoint PointAt( double ) const;
74  ON_3dVector DerivativeAt(
75  int, // desired derivative ( >= 0 )
76  double // parameter
77  ) const;
78 
79  ON_3dVector TangentAt( double ) const; // returns unit tangent
80  ON_3dVector CurvatureAt( double ) const; // returns curvature vector
81 
82  // returns parameters of point on ellipse that is closest to given point
83  bool ClosestPointTo(
84  const ON_3dPoint&,
85  double*
86  ) const;
87  // returns point on ellipse that is closest to given point
88  ON_3dPoint ClosestPointTo(
89  const ON_3dPoint&
90  ) const;
91 
92  // evaluate ellipse's implicit equation in plane
93  double EquationAt( const ON_2dPoint& ) const;
94  ON_2dVector GradientAt( const ON_2dPoint& ) const;
95 
96  // rotate ellipse about its center
97  bool Rotate(
98  double, // sin(angle)
99  double, // cos(angle)
100  const ON_3dVector& // axis of rotation
101  );
102  bool Rotate(
103  double, // angle in radians
104  const ON_3dVector& // axis of rotation
105  );
106 
107  // rotate ellipse about a point and axis
108  bool Rotate(
109  double, // sin(angle)
110  double, // cos(angle)
111  const ON_3dVector&, // axis of rotation
112  const ON_3dPoint& // center of rotation
113  );
114  bool Rotate(
115  double, // angle in radians
116  const ON_3dVector&, // axis of rotation
117  const ON_3dPoint& // center of rotation
118  );
119 
120  bool Translate(
121  const ON_3dVector&
122  );
123 
124  // parameterization of NURBS curve does not match ellipse's transcendental paramaterization
125  int GetNurbForm( ON_NurbsCurve& ) const; // returns 0=failure, 2=success
126 
127 public: // members left public
128  // The center of the ellipse is at the plane's origin. The axes of the
129  // ellipse are the plane's x and y axes. The equation of the ellipse
130  // with respect to the plane is (x/m_r[0])^2 + (y/m_r[1])^2 = 1;
131  ON_Plane plane;
132  double radius[2]; // radii for x and y axes (both must be > 0)
133 };
134 
135 #endif
ON_Circle is a circle in 3d. The cirle is represented by a radius and an orthonormal frame of the pla...
Definition: opennurbs_circle.h:32
Definition: opennurbs_point.h:277
Definition: opennurbs_ellipse.h:23
Definition: opennurbs_nurbscurve.h:26
Definition: opennurbs_point.h:460
Definition: opennurbs_plane.h:20
Definition: opennurbs_point.h:839
Definition: opennurbs_point.h:1152