QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_polyline.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#if !defined(ON_POLYLINE_INC_)
17#define ON_POLYLINE_INC_
18
20{
21public:
26
27 // Description:
28 // Create a regular polygon inscribed in a circle.
29 // The vertices of the polygon will be on the circle.
30 // Parameters:
31 // circle - [in]
32 // side_count - [in] (>=3) number of sides
33 // Returns:
34 // true if successful. false if circle is invalid or
35 // side_count < 3.
36 bool CreateInscribedPolygon(
37 const ON_Circle& circle,
38 int side_count
39 );
40
41 // Description:
42 // Create a regular polygon circumscribe about a circle.
43 // The midpoints of the polygon's edges will be tanget to the
44 // circle.
45 // Parameters:
46 // circle - [in]
47 // side_count - [in] (>=3) number of sides
48 // Returns:
49 // true if successful. false if circle is invalid or
50 // side_count < 3.
51 bool CreateCircumscribedPolygon(
52 const ON_Circle& circle,
53 int side_count
54 );
55
56 // Description:
57 // Create a regular star polygon.
58 // The star begins at circle.PointAt(0) and the vertices alternate
59 // between being on circle and begin on a concentric circle of
60 // other_radius.
61 // Parameters:
62 // circle - [in] circle star polygon starts on
63 // other_radius - [in] radius of other circle
64 // corner_count - [in] (>=3) number of corners on circle
65 // There will be 2*corner_count sides and 2*corner_count
66 // vertices.
67 // Returns:
68 // true if successful. false if circle is invalid, other_radius < 0.0,
69 // or side_count < 3.
70 bool CreateStarPolygon(
71 const ON_Circle& circle,
72 double other_radius,
73 int side_count
74 );
75
76 // Description:
77 // Checks that polyline has at least two points
78 // and that sequential points are distinct. If the
79 // polyline has 2 or 3 points, then the start and end
80 // point must be distinct.
81 // Parameters:
82 // tolerance - [in] tolerance used to check for duplicate points.
83 // Returns:
84 // true if polyline is valid.
85 // See Also:
86 // ON_Polyline::Clean.
87 bool IsValid(
88 double tolerance = 0.0
89 ) const;
90
91 // Description:
92 // Removes duplicate points that result in zero length segments.
93 // Parameters:
94 // tolerance - [in] tolerance used to check for duplicate points.
95 // Returns:
96 // Number of points removed.
97 // Remarks:
98 // If the distance between points polyline[i] and polyline[i+1]
99 // is <= tolerance, then the point with index (i+1) is removed.
100 int Clean(
101 double tolerance = 0.0
102 );
103
104 // Returns:
105 // Number of points in the polyline.
106 int PointCount() const;
107
108 // Returns:
109 // Number of segments in the polyline.
110 int SegmentCount() const;
111
112 // Description:
113 // Test a polyline to see if it is closed.
114 // Returns:
115 // true if polyline has 4 or more points, the distance between the
116 // start and end points is <= tolerance, and there is a
117 // point in the polyline whose distance from the start and end
118 // points is > tolerance.
119 bool IsClosed(
120 double tolerance = 0.0
121 ) const;
122
123
124 // Returns:
125 // Length of the polyline.
126 double Length() const;
127
128 // Parameters:
129 // segment_index - [in] zero based segment index
130 // Returns:
131 // vector = point[segment_index+1] - point[segment_index].
132 ON_3dVector SegmentDirection (
133 int segment_index
134 ) const;
135
136 // Parameters:
137 // segment_index - [in] zero based segment index
138 // Returns:
139 // Unit vector in the direction of the segment
140 ON_3dVector SegmentTangent (
141 int segment_index
142 ) const;
143
144 // Description:
145 // Evaluate the polyline location at a parameter.
146 // Parameters:
147 // t - [in] the i-th segment goes from i <= t < i+1
148 ON_3dPoint PointAt( double t ) const;
149
150 // Description:
151 // Evaluate the polyline first derivative at a parameter.
152 // Parameters:
153 // t - [in] the i-th segment goes from i <= t < i+1
154 ON_3dVector DerivativeAt( double t ) const;
155
156 // Description:
157 // Evaluate the polyline unit tangent at a parameter.
158 // Parameters:
159 // t - [in] the i-th segment goes from i <= t < i+1
160 ON_3dVector TangentAt( double t ) const;
161
162 // Description:
163 // Find a point on the polyline that is closest
164 // to test_point.
165 // Parameters:
166 // test_point - [in]
167 // t - [out] parameter for a point on the polyline that
168 // is closest to test_point. If mulitple solutions
169 // exist, then the smallest solution is returned.
170 // Returns:
171 // true if successful.
172 bool ClosestPointTo(
173 const ON_3dPoint& test_point,
174 double* t
175 ) const;
176
177 // Description:
178 // Find a point on the polyline that is closest
179 // to test_point.
180 // Parameters:
181 // test_point - [in]
182 // t - [out] parameter for a point on the polyline that
183 // is closest to test_point. If mulitple solutions
184 // exist, then the smallest solution is returned.
185 // segment_index0 - [in] index of segment where search begins
186 // segment_index1 - [in] index of segment where search ends
187 // This segment is NOT searched.
188 // Example:
189 // Search segments 3,4, and 5 for the point closest to (0,0,0).
190 // double t;
191 // ClosestPointTo( ON_3dPoint(0,0,0), &t, 3, 6 );
192 // Returns:
193 // true if successful.
194 bool ClosestPointTo(
195 const ON_3dPoint& test_point,
196 double* t,
197 int segment_index0, // index of segment where search begins
198 int segment_index1 // index + 1 of segment where search stops
199 ) const;
200
201 // Description:
202 // Find a point on the polyline that is closest
203 // to test_point.
204 // Parameters:
205 // test_point - [in]
206 // Returns:
207 // point on polyline.
208 ON_3dPoint ClosestPointTo(
209 const ON_3dPoint& test_point
210 ) const;
211
212};
213
214#endif
Definition opennurbs_array.h:398
ON_3dPointArray & operator=(const ON_3dPointArray &)
Definition opennurbs_array.cpp:149
Definition opennurbs_point.h:403
Definition opennurbs_point.h:931
Definition opennurbs_circle.h:33
Definition opennurbs_polyline.h:20
#define ON_CLASS
Definition opennurbs_defines.h:91