-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathICurveI.java
336 lines (254 loc) · 11.2 KB
/
ICurveI.java
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/*---
iGeo - http://igeo.jp
Copyright (c) 2002-2013 Satoru Sugihara
This file is part of iGeo.
iGeo is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, version 3.
iGeo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with iGeo. If not, see <http://www.gnu.org/licenses/>.
---*/
package igeo;
/**
Abstract interface of NURBS curve.
@author Satoru Sugihara
*/
public interface ICurveI extends ICurveOp, ITransformable{
/**
@return fixed value but in wrapper class
*/
public ICurveGeo get();
/**
@return duplicated instance
*/
public ICurveI dup();
public boolean isValid();
public IVecI pt(double u);
public IVecI pt(IDoubleI u);
public IVecI tan(double u);
public IVecI tan(IDoubleI u);
public IVecI cp(int i);
public IVecI cp(IIntegerI i);
public IVecI ep(int i);
public IVecI ep(IIntegerI i);
/** all control points */
public IVecI[] cps();
/** approximate invert projection from 3D location to interanl parameter U (closest point on curve) */
public double u(IVecI pt);
public double u(ISwitchE r, IVecI pt);
public IDoubleI u(ISwitchR r, IVecI pt);
/** approximate invert projection from 2D location to interanl parameter U */
public double u(IVec2I pt);
public double u(ISwitchE r, IVec2I pt);
public IDoubleI u(ISwitchR r, IVec2I pt);
/** find approximately closest point on a curve */
public IVecI closePt(IVecI pt);
/** find approximately closest point on a curve on 2D*/
public IVecI closePt(IVec2I pt);
/** distance to the closest point on a curve */
public double dist(IVecI pt);
/** distance to the closest point on a curve on 2D*/
public double dist(IVec2I pt);
// maybe those are only for ICurve & ICurveGeo, not ICurveR
//
/** add control point at the end and rebuild the curve.
note that a knots is rebuilt with default equal intervals
and destroy original knot intervals if variable, like circle.
*/
//public ICurveI addCP(IVecI pt);
/** add control point at i and rebuild the curve.
note that a knots is rebuilt with default equal intervals
and destroy original knot intervals if variable, like circle.
*/
//public ICurveI addCP(int i, IVecI pt);
/** add control points at the end and rebuild the curve.
note that a knots is rebuilt with default equal intervals
and destroy original knot intervals if variable, like circle.
*/
//public ICurveI addCP(IVecI[] pt);
/** add control points at i and rebuild the curve.
note that a knots is rebuilt with default equal intervals
and destroy original knot intervals if variable, like circle.
*/
//public ICurveI addCP(int i, IVecI[] pt);
/** alias of addCP(int,IVecI) */
//public ICurveI insertCP(int i, IVecI pt);
/** alias of addCP(int,IVecI[]) */
//public ICurveI insertCP(int i, IVecI[] pt);
/** removing control point at the end and rebuild the curve.
note that a knots is rebuilt with default equal interval
and destroy original knot intervals if variable, like circle.
*/
//public ICurveI removeCP();
/** removing control point at i and rebuild the curve
note that a knots is rebuilt with default equal interval
and destroy original knot intervals if variable, like circle.
*/
//public ICurveI removeCP(int i);
/** removing control point from indexFrom to indexTo-1 and rebuild the curve
note that a knots is rebuilt with default equal interval
and destroy original knot intervals if variable, like circle.
*/
//public ICurveI removeCP(int indexFrom int indexTo);
/** close curve with the current control points.
it changes total number of control points and knot vector dependng on the degree.
new knot vector has equal default intervals destroying original variable intervals.
*/
//public ICurveI close();
public double knot(int i);
public IDoubleI knot(IIntegerI i);
/** all knot values */
public double[]knots();
public double[] knots(ISwitchE e);
public IDoubleI[] knots(ISwitchR r);
public int knotNum();
//public IIntegerI knotNumR();
public int knotNum(ISwitchE e);
public IIntegerI knotNum(ISwitchR r);
/**
@return returns true if any of control point has non-default(1.0) weight otherwise false.
*/
public boolean isRational();
public boolean isRational(ISwitchE e);
public IBoolI isRational(ISwitchR r);
public int deg();
//public IIntegerI degR();
public int deg(ISwitchE e);
public IIntegerI deg(ISwitchR r);
/** change degree. this operation is costly because it needs to rebuild the whole knots and basisFunction */
//public ICurveI deg(int d);
//sholud I not allow to record changing degree?
//public ICurveI deg(IDoubeI d);
public int num(); // equals to cpNum
//public IIntegerI numR(); // equals to cpNum
public int num(ISwitchE e); // equals to cpNum
public IIntegerI num(ISwitchR r); // equals to cpNum
public int cpNum(); //
//public IIntegerI cpNumR(); //
public int cpNum(ISwitchE e); //
public IIntegerI cpNum(ISwitchR r); //
public IVecI start();
public IVecI end();
public IVecI startCP();
public IVecI endCP();
/** parametrically mid point of a curve */
public IVecI mid();
/** returns center of geometry object */
public IVecI center();
public int epNum();
//public IIntegerI epNumR();
public int epNum(ISwitchE e);
public IIntegerI epNum(ISwitchR r);
public double len();
//public IDouble lenR();
public double len(ISwitchE e);
public IDouble len(ISwitchR r);
// epIdx: 0-epNum, epFraction: 0-1 or -1-0
public double u(int epIdx, double epFraction);
public IDoubleI u(IInteger epIdx, IDouble epFraction);
public double ustart();
public double uend();
//public IDoubleI ustartR();
//public IDoubleI uendR();
public double ustart(ISwitchE e);
public double uend(ISwitchE e);
public IDoubleI ustart(ISwitchR r);
public IDoubleI uend(ISwitchR r);
public boolean isClosed();
//public IBoolI isClosedR();
public boolean isClosed(ISwitchE e);
public IBoolI isClosed(ISwitchR r);
/** reverse U coordintates direction of curve, without creating a new object */
public ICurveI rev();
/** alias of rev() */
public ICurveI revU();
/** alias of rev() */
public ICurveI flipU();
/***************************************************************************
* transformation: API of ITransformable inteface
***************************************************************************/
public ICurveI add(double x, double y, double z);
public ICurveI add(IDoubleI x, IDoubleI y, IDoubleI z);
public ICurveI add(IVecI v);
public ICurveI sub(double x, double y, double z);
public ICurveI sub(IDoubleI x, IDoubleI y, IDoubleI z);
public ICurveI sub(IVecI v);
public ICurveI mul(IDoubleI v);
public ICurveI mul(double v);
public ICurveI div(IDoubleI v);
public ICurveI div(double v);
public ICurveI neg();
/** same with neg */
//public ICurveI rev(); // rev is used in curve to revrse u parameter
public ICurveI flip();
/** scale add */
public ICurveI add(IVecI v, double f);
public ICurveI add(IVecI v, IDoubleI f);
public ICurveI rot(IVecI axis, IDoubleI angle);
public ICurveI rot(IVecI axis, double angle);
public ICurveI rot(IVecI center, IVecI axis, IDoubleI angle);
public ICurveI rot(IVecI center, IVecI axis, double angle);
/** rotate to destination direction vector */
public ICurveI rot(IVecI axis, IVecI destDir);
/** rotate to destination point location */
public ICurveI rot(IVecI center, IVecI axis, IVecI destPt);
/** alias of mul */
public ICurveI scale(IDoubleI f);
public ICurveI scale(double f);
public ICurveI scale(IVecI center, IDoubleI f);
public ICurveI scale(IVecI center, double f);
/** scale only in 1 direction */
public ICurveI scale1d(IVecI axis, double f);
public ICurveI scale1d(IVecI axis, IDoubleI f);
public ICurveI scale1d(IVecI center, IVecI axis, double f);
public ICurveI scale1d(IVecI center, IVecI axis, IDoubleI f);
/** reflect(mirror) 3 dimensionally to the other side of the plane */
public ICurveI ref(IVecI planeDir);
public ICurveI ref(IVecI center, IVecI planeDir);
/** mirror is alias of ref */
public ICurveI mirror(IVecI planeDir);
public ICurveI mirror(IVecI center, IVecI planeDir);
/** shear operation */
public ICurveI shear(double sxy, double syx, double syz,
double szy, double szx, double sxz);
public ICurveI shear(IDoubleI sxy, IDoubleI syx, IDoubleI syz,
IDoubleI szy, IDoubleI szx, IDoubleI sxz);
public ICurveI shear(IVecI center, double sxy, double syx, double syz,
double szy, double szx, double sxz);
public ICurveI shear(IVecI center, IDoubleI sxy, IDoubleI syx, IDoubleI syz,
IDoubleI szy, IDoubleI szx, IDoubleI sxz);
public ICurveI shearXY(double sxy, double syx);
public ICurveI shearXY(IDoubleI sxy, IDoubleI syx);
public ICurveI shearXY(IVecI center, double sxy, double syx);
public ICurveI shearXY(IVecI center, IDoubleI sxy, IDoubleI syx);
public ICurveI shearYZ(double syz, double szy);
public ICurveI shearYZ(IDoubleI syz, IDoubleI szy);
public ICurveI shearYZ(IVecI center, double syz, double szy);
public ICurveI shearYZ(IVecI center, IDoubleI syz, IDoubleI szy);
public ICurveI shearZX(double szx, double sxz);
public ICurveI shearZX(IDoubleI szx, IDoubleI sxz);
public ICurveI shearZX(IVecI center, double szx, double sxz);
public ICurveI shearZX(IVecI center, IDoubleI szx, IDoubleI sxz);
/** translate is alias of add() */
public ICurveI translate(double x, double y, double z);
public ICurveI translate(IDoubleI x, IDoubleI y, IDoubleI z);
public ICurveI translate(IVecI v);
public ICurveI transform(IMatrix3I mat);
public ICurveI transform(IMatrix4I mat);
public ICurveI transform(IVecI xvec, IVecI yvec, IVecI zvec);
public ICurveI transform(IVecI xvec, IVecI yvec, IVecI zvec, IVecI translate);
/** mv() is alias of add() */
public ICurveI mv(double x, double y, double z);
public ICurveI mv(IDoubleI x, IDoubleI y, IDoubleI z);
public ICurveI mv(IVecI v);
/** cp() is alias of dup() */
public ICurveI cp();
/** cp() is alias of dup().add() */
public ICurveI cp(double x, double y, double z);
public ICurveI cp(IDoubleI x, IDoubleI y, IDoubleI z);
public ICurveI cp(IVecI v);
}