opennurbs_cone.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(ON_CONE_INC_)
18 #define ON_CONE_INC_
19 
20 class ON_NurbsSurface;
21 class ON_Brep;
22 
23 // Description:
24 // Lightweight right circular cone. Use ON_ConeSurface if
25 // you need ON_Cone geometry as a virtual ON_Surface.
26 class ON_CLASS ON_Cone
27 {
28 public:
29 
30  // Creates a cone with world XY plane as the base plane,
31  // center = (0,0,0), radius = 0.0, height = 0.0.
32  ON_Cone();
33 
34  // See ON_Cone::Create.
35  ON_Cone(
36  const ON_Plane& plane,
37  double height,
38  double radius
39  );
40 
41  ~ON_Cone();
42 
43  // Description:
44  // Creates a right circular cone from a plane, height,
45  // and radius.
46  // plane - [in] The apex of cone is at plane.origin and
47  // the axis of the cone is plane.zaxis.
48  // height - [in] The center of the base is height*plane.zaxis.
49  // radius - [in] tan(cone angle) = radius/height
50  bool Create(
51  const ON_Plane& plane,
52  double height,
53  double radius
54  );
55 
56  // Returns true if plane is valid, height is not zero, and
57  // radius is not zero.
58  bool IsValid() const;
59 
60  // Returns:
61  // Center of base circle.
62  // Remarks:
63  // The base point is plane.origin + height*plane.zaxis.
64  ON_3dPoint BasePoint() const;
65 
66  // Returns:
67  // Point at the tip of the cone.
68  // Remarks:
69  // The apex point is plane.origin.
70  const ON_3dPoint& ApexPoint() const;
71 
72  // Returns:
73  // Unit vector axis of cone.
74  const ON_3dVector& Axis() const;
75 
76  // Returns:
77  // The angle (in radians) between the axis and the
78  // side of the cone.
79  // The angle and the height have the same sign.
80  double AngleInRadians() const;
81 
82  // Returns:
83  // The angle Iin degrees) between the axis and the side.
84  // The angle and the height have the same sign.
85  double AngleInDegrees() const;
86 
87  // evaluate parameters and return point
88  // Parameters:
89  // radial_parameter - [in] 0.0 to 2.0*ON_PI
90  // height_parameter - [in] 0 = apex, height = base
91  ON_3dPoint PointAt(
92  double radial_parameter,
93  double height_parameter
94  ) const;
95 
96  // Parameters:
97  // radial_parameter - [in] (in radians) 0.0 to 2.0*ON_PI
98  // height_parameter - [in] 0 = apex, height = base
99  // Remarks:
100  // If radius>0 and height>0, then the normal points "out"
101  // when height_parameter >= 0.
102  ON_3dVector NormalAt(
103  double radial_parameter,
104  double height_parameter
105  ) const;
106 
107  // Description:
108  // Get iso curve circle at a specified height.
109  // Parameters:
110  // height_parameter - [in] 0 = apex, height = base
111  ON_Circle CircleAt(
112  double height_parameter
113  ) const;
114 
115  // Description:
116  // Get iso curve line segment at a specified angle.
117  // Parameters:
118  // radial_parameter - [in] (in radians) 0.0 to 2.0*ON_PI
119  ON_Line LineAt(
120  double radial_parameter
121  ) const;
122 
123  // returns parameters of point on cone that is closest to given point
124  bool ClosestPointTo(
125  ON_3dPoint point,
126  double* radial_parameter,
127  double* height_parameter
128  ) const;
129 
130  // returns point on cone that is closest to given point
131  ON_3dPoint ClosestPointTo(
132  ON_3dPoint
133  ) const;
134 
135  bool Transform( const ON_Xform& );
136 
137  // rotate cone about its origin
138  bool Rotate(
139  double sin_angle,
140  double cos_angle,
141  const ON_3dVector& axis_of_rotation
142  );
143 
144  bool Rotate(
145  double angle_in_radians,
146  const ON_3dVector& axis_of_rotation
147  );
148 
149  // rotate cone about a point and axis
150  bool Rotate(
151  double sin_angle,
152  double cos_angle,
153  const ON_3dVector& axis_of_rotation,
154  const ON_3dPoint& center_of_rotation
155  );
156  bool Rotate(
157  double angle_in_radians,
158  const ON_3dVector& axis_of_rotation,
159  const ON_3dPoint& center_of_rotation
160  );
161 
162  bool Translate(
163  const ON_3dVector& delta
164  );
165 
166  /*
167  returns:
168  0 = failure
169  2 = success
170  */
171  int GetNurbForm( ON_NurbsSurface& ) const;
172 
173  /*
174  Description:
175  Creates a surface of revolution definition of the cylinder.
176  Parameters:
177  srf - [in] if not nullptr, then this srf is used.
178  Result:
179  A surface of revolution or nullptr if the cylinder is not
180  valid or is infinite.
181  */
182  ON_RevSurface* RevSurfaceForm( ON_RevSurface* srf = nullptr ) const;
183 
184 public:
185  ON_Plane plane; // apex = plane.origin, axis = plane.zaxis
186  double height; // not zero
187  double radius; // not zero
188 };
189 
190 #endif
Definition: opennurbs_nurbssurface.h:62
Lightweight right circular cone. Use ON_ConeSurface if you need ON_Cone geometry as a virtual ON_Surf...
Definition: opennurbs_cone.h:27
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_xform.h:28
Definition: opennurbs_line.h:20
Definition: opennurbs_brep.h:1472
Definition: opennurbs_point.h:460
Definition: opennurbs_plane.h:20
surface of revolution
Definition: opennurbs_revsurface.h:21
Definition: opennurbs_point.h:1152