forked from mcneel/opennurbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opennurbs_cone.h
190 lines (162 loc) · 4.83 KB
/
opennurbs_cone.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/* $NoKeywords: $ */
/*
//
// Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
// McNeel & Associates.
//
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
//
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
//
////////////////////////////////////////////////////////////////
*/
#if !defined(ON_CONE_INC_)
#define ON_CONE_INC_
class ON_NurbsSurface;
class ON_Brep;
// Description:
// Lightweight right circular cone. Use ON_ConeSurface if
// you need ON_Cone geometry as a virtual ON_Surface.
class ON_CLASS ON_Cone
{
public:
// Creates a cone with world XY plane as the base plane,
// center = (0,0,0), radius = 0.0, height = 0.0.
ON_Cone();
// See ON_Cone::Create.
ON_Cone(
const ON_Plane& plane,
double height,
double radius
);
~ON_Cone();
// Description:
// Creates a right circular cone from a plane, height,
// and radius.
// plane - [in] The apex of cone is at plane.origin and
// the axis of the cone is plane.zaxis.
// height - [in] The center of the base is height*plane.zaxis.
// radius - [in] tan(cone angle) = radius/height
bool Create(
const ON_Plane& plane,
double height,
double radius
);
// Returns true if plane is valid, height is not zero, and
// radius is not zero.
bool IsValid() const;
// Returns:
// Center of base circle.
// Remarks:
// The base point is plane.origin + height*plane.zaxis.
ON_3dPoint BasePoint() const;
// Returns:
// Point at the tip of the cone.
// Remarks:
// The apex point is plane.origin.
const ON_3dPoint& ApexPoint() const;
// Returns:
// Unit vector axis of cone.
const ON_3dVector& Axis() const;
// Returns:
// The angle (in radians) between the axis and the
// side of the cone.
// The angle and the height have the same sign.
double AngleInRadians() const;
// Returns:
// The angle Iin degrees) between the axis and the side.
// The angle and the height have the same sign.
double AngleInDegrees() const;
// evaluate parameters and return point
// Parameters:
// radial_parameter - [in] 0.0 to 2.0*ON_PI
// height_parameter - [in] 0 = apex, height = base
ON_3dPoint PointAt(
double radial_parameter,
double height_parameter
) const;
// Parameters:
// radial_parameter - [in] (in radians) 0.0 to 2.0*ON_PI
// height_parameter - [in] 0 = apex, height = base
// Remarks:
// If radius>0 and height>0, then the normal points "out"
// when height_parameter >= 0.
ON_3dVector NormalAt(
double radial_parameter,
double height_parameter
) const;
// Description:
// Get iso curve circle at a specified height.
// Parameters:
// height_parameter - [in] 0 = apex, height = base
ON_Circle CircleAt(
double height_parameter
) const;
// Description:
// Get iso curve line segment at a specified angle.
// Parameters:
// radial_parameter - [in] (in radians) 0.0 to 2.0*ON_PI
ON_Line LineAt(
double radial_parameter
) const;
// returns parameters of point on cone that is closest to given point
bool ClosestPointTo(
ON_3dPoint point,
double* radial_parameter,
double* height_parameter
) const;
// returns point on cone that is closest to given point
ON_3dPoint ClosestPointTo(
ON_3dPoint
) const;
bool Transform( const ON_Xform& );
// rotate cone about its origin
bool Rotate(
double sin_angle,
double cos_angle,
const ON_3dVector& axis_of_rotation
);
bool Rotate(
double angle_in_radians,
const ON_3dVector& axis_of_rotation
);
// rotate cone about a point and axis
bool Rotate(
double sin_angle,
double cos_angle,
const ON_3dVector& axis_of_rotation,
const ON_3dPoint& center_of_rotation
);
bool Rotate(
double angle_in_radians,
const ON_3dVector& axis_of_rotation,
const ON_3dPoint& center_of_rotation
);
bool Translate(
const ON_3dVector& delta
);
/*
returns:
0 = failure
2 = success
*/
int GetNurbForm( ON_NurbsSurface& ) const;
/*
Description:
Creates a surface of revolution definition of the cylinder.
Parameters:
srf - [in] if not nullptr, then this srf is used.
Result:
A surface of revolution or nullptr if the cylinder is not
valid or is infinite.
*/
ON_RevSurface* RevSurfaceForm( ON_RevSurface* srf = nullptr ) const;
public:
ON_Plane plane; // apex = plane.origin, axis = plane.zaxis
double height; // not zero
double radius; // not zero
};
#endif