geomerative 1.1.0-java → 2.0.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.mvn/extensions.xml +1 -1
  4. data/.mvn/wrapper/maven-wrapper.properties +1 -1
  5. data/CHANGELOG.md +3 -0
  6. data/COPYING.md +1 -1
  7. data/README.md +0 -1
  8. data/Rakefile +2 -15
  9. data/docs/_includes/header.html +6 -6
  10. data/docs/_includes/icon-github.svg +3 -1
  11. data/docs/_includes/icon-twitter.svg +3 -1
  12. data/docs/_includes/navigation.html +18 -18
  13. data/docs/_sass/_base.scss +79 -79
  14. data/docs/_sass/_layout.scss +137 -137
  15. data/docs/_sass/_syntax-highlighting.scss +64 -64
  16. data/docs/index.html +18 -18
  17. data/examples/data/bot1.svg +1 -1
  18. data/examples/data/lion.svg +156 -156
  19. data/examples/data/ruby.svg +1 -1
  20. data/geomerative.gemspec +1 -2
  21. data/lib/geomerative/version.rb +1 -1
  22. data/mvnw +234 -0
  23. data/mvnw.cmd +145 -0
  24. data/pom.rb +14 -13
  25. data/pom.xml +14 -13
  26. data/src/geomerative/FastRClip.java +2149 -2156
  27. data/src/geomerative/RClip.java +2237 -2539
  28. data/src/geomerative/RClosest.java +33 -31
  29. data/src/geomerative/RCommand.java +1750 -1758
  30. data/src/geomerative/RContour.java +290 -292
  31. data/src/geomerative/RFont.java +277 -246
  32. data/src/geomerative/RG.java +722 -727
  33. data/src/geomerative/RGeomElem.java +967 -960
  34. data/src/geomerative/RGroup.java +508 -467
  35. data/src/geomerative/RMatrix.java +304 -289
  36. data/src/geomerative/RMesh.java +241 -229
  37. data/src/geomerative/RPath.java +924 -925
  38. data/src/geomerative/RPoint.java +391 -391
  39. data/src/geomerative/RPolygon.java +998 -988
  40. data/src/geomerative/RRectangle.java +43 -52
  41. data/src/geomerative/RSVG.java +480 -516
  42. data/src/geomerative/RShape.java +1767 -1777
  43. data/src/geomerative/RStrip.java +173 -176
  44. data/src/geomerative/RStyle.java +197 -194
  45. data/src/org/apache/batik/svggen/font/Font.java +141 -142
  46. data/src/org/apache/batik/svggen/font/Glyph.java +102 -71
  47. data/src/org/apache/batik/svggen/font/Point.java +12 -12
  48. data/src/org/apache/batik/svggen/font/RandomAccessFileEmulator.java +14 -12
  49. data/src/org/apache/batik/svggen/font/table/ClassDef.java +12 -12
  50. data/src/org/apache/batik/svggen/font/table/ClassDefFormat1.java +27 -24
  51. data/src/org/apache/batik/svggen/font/table/ClassDefFormat2.java +20 -17
  52. data/src/org/apache/batik/svggen/font/table/CmapFormat.java +43 -43
  53. data/src/org/apache/batik/svggen/font/table/CmapFormat0.java +33 -26
  54. data/src/org/apache/batik/svggen/font/table/CmapFormat2.java +25 -20
  55. data/src/org/apache/batik/svggen/font/table/CmapFormat4.java +106 -96
  56. data/src/org/apache/batik/svggen/font/table/CmapFormat6.java +36 -32
  57. data/src/org/apache/batik/svggen/font/table/CmapIndexEntry.java +69 -49
  58. data/src/org/apache/batik/svggen/font/table/CmapTable.java +50 -50
  59. data/src/org/apache/batik/svggen/font/table/Coverage.java +19 -19
  60. data/src/org/apache/batik/svggen/font/table/CoverageFormat1.java +30 -27
  61. data/src/org/apache/batik/svggen/font/table/CoverageFormat2.java +26 -24
  62. data/src/org/apache/batik/svggen/font/table/CvtTable.java +16 -16
  63. data/src/org/apache/batik/svggen/font/table/Device.java +32 -32
  64. data/src/org/apache/batik/svggen/font/table/DirectoryEntry.java +39 -39
  65. data/src/org/apache/batik/svggen/font/table/Feature.java +26 -23
  66. data/src/org/apache/batik/svggen/font/table/FeatureList.java +37 -35
  67. data/src/org/apache/batik/svggen/font/table/FeatureRecord.java +22 -22
  68. data/src/org/apache/batik/svggen/font/table/FeatureTags.java +4 -3
  69. data/src/org/apache/batik/svggen/font/table/FpgmTable.java +9 -9
  70. data/src/org/apache/batik/svggen/font/table/GlyfCompositeComp.java +134 -132
  71. data/src/org/apache/batik/svggen/font/table/GlyfCompositeDescript.java +123 -122
  72. data/src/org/apache/batik/svggen/font/table/GlyfDescript.java +44 -44
  73. data/src/org/apache/batik/svggen/font/table/GlyfSimpleDescript.java +110 -109
  74. data/src/org/apache/batik/svggen/font/table/GlyfTable.java +46 -46
  75. data/src/org/apache/batik/svggen/font/table/GlyphDescription.java +25 -13
  76. data/src/org/apache/batik/svggen/font/table/GposTable.java +26 -23
  77. data/src/org/apache/batik/svggen/font/table/GsubTable.java +85 -82
  78. data/src/org/apache/batik/svggen/font/table/HeadTable.java +131 -131
  79. data/src/org/apache/batik/svggen/font/table/HheaTable.java +80 -80
  80. data/src/org/apache/batik/svggen/font/table/HmtxTable.java +50 -49
  81. data/src/org/apache/batik/svggen/font/table/KernSubtable.java +29 -27
  82. data/src/org/apache/batik/svggen/font/table/KernSubtableFormat0.java +35 -32
  83. data/src/org/apache/batik/svggen/font/table/KernSubtableFormat2.java +28 -26
  84. data/src/org/apache/batik/svggen/font/table/KernTable.java +36 -31
  85. data/src/org/apache/batik/svggen/font/table/KerningPair.java +27 -23
  86. data/src/org/apache/batik/svggen/font/table/LangSys.java +28 -26
  87. data/src/org/apache/batik/svggen/font/table/LangSysRecord.java +22 -22
  88. data/src/org/apache/batik/svggen/font/table/Ligature.java +24 -24
  89. data/src/org/apache/batik/svggen/font/table/LigatureSet.java +24 -24
  90. data/src/org/apache/batik/svggen/font/table/LigatureSubst.java +9 -9
  91. data/src/org/apache/batik/svggen/font/table/LigatureSubstFormat1.java +30 -30
  92. data/src/org/apache/batik/svggen/font/table/LocaTable.java +37 -37
  93. data/src/org/apache/batik/svggen/font/table/Lookup.java +41 -40
  94. data/src/org/apache/batik/svggen/font/table/LookupList.java +34 -34
  95. data/src/org/apache/batik/svggen/font/table/LookupSubtableFactory.java +7 -5
  96. data/src/org/apache/batik/svggen/font/table/MaxpTable.java +96 -96
  97. data/src/org/apache/batik/svggen/font/table/NameRecord.java +64 -65
  98. data/src/org/apache/batik/svggen/font/table/NameTable.java +33 -33
  99. data/src/org/apache/batik/svggen/font/table/Os2Table.java +196 -196
  100. data/src/org/apache/batik/svggen/font/table/Panose.java +14 -12
  101. data/src/org/apache/batik/svggen/font/table/PostTable.java +338 -338
  102. data/src/org/apache/batik/svggen/font/table/PrepTable.java +9 -9
  103. data/src/org/apache/batik/svggen/font/table/Program.java +15 -15
  104. data/src/org/apache/batik/svggen/font/table/RangeRecord.java +26 -25
  105. data/src/org/apache/batik/svggen/font/table/Script.java +38 -38
  106. data/src/org/apache/batik/svggen/font/table/ScriptList.java +42 -42
  107. data/src/org/apache/batik/svggen/font/table/ScriptRecord.java +22 -22
  108. data/src/org/apache/batik/svggen/font/table/ScriptTags.java +2 -1
  109. data/src/org/apache/batik/svggen/font/table/SingleSubst.java +15 -16
  110. data/src/org/apache/batik/svggen/font/table/SingleSubstFormat1.java +33 -33
  111. data/src/org/apache/batik/svggen/font/table/SingleSubstFormat2.java +32 -32
  112. data/src/org/apache/batik/svggen/font/table/Table.java +171 -170
  113. data/src/org/apache/batik/svggen/font/table/TableDirectory.java +55 -55
  114. data/src/org/apache/batik/svggen/font/table/TableFactory.java +92 -93
  115. metadata +10 -11
  116. data/.travis.yml +0 -9
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Copyright 2004-2008 Ricard Marxer <email@ricardmarxer.com>
3
3
  *
4
- This file is part of Geomerative.
4
+ * This file is part of Geomerative.
5
5
  *
6
6
  * Geomerative is free software: you can redistribute it and/or modify it under
7
7
  * the terms of the GNU General Public License as published by the Free Software
@@ -22,398 +22,398 @@ package geomerative;
22
22
  * RPoint is a very simple interface for creating, holding and drawing 2D
23
23
  * points.
24
24
  *
25
- * @eexample RPoint
26
- * @usage Geometry
27
- * @related x
28
- * @related y
25
+ RPoint
26
+ * Geometry
27
+ * x
28
+ * y
29
29
  */
30
30
  public class RPoint {
31
31
 
32
- /**
33
- * The x coordinate of the point.
34
- *
35
- * @eexample RPoint_x
36
- * @usage Geometry
37
- * @related y
38
- */
39
- public float x;
40
-
41
- /**
42
- * The y coordinate of the point.
43
- *
44
- * @eexample RPoint_y
45
- * @usage Geometry
46
- * @related x
47
- */
48
- public float y;
49
-
50
- /**
51
- * Create a new point, given the coordinates.
52
- *
53
- * @eexample RPoint_constructor
54
- * @usage Geometry
55
- * @param x the x coordinate of the new point
56
- * @param y the y coordinate of the new point
57
- * @related x
58
- * @related y
59
- */
60
- public RPoint(float x, float y) {
61
- this.x = x;
62
- this.y = y;
63
- }
64
-
65
- public RPoint(double x, double y) {
66
- this.x = (float) x;
67
- this.y = (float) y;
68
- }
69
-
70
- /**
71
- * Create a new point at (0, 0).
72
- *
73
- * @eexample RPoint_constructor
74
- * @usage Geometry
75
- * @related x
76
- * @related y
77
- */
78
- public RPoint() {
79
- x = 0;
80
- y = 0;
81
- }
82
-
83
- /**
84
- * Copy a point.
85
- *
86
- * @eexample RPoint_constructor
87
- * @usage Geometry
88
- * @param p the point we wish to make a copy of
89
- * @related x
90
- * @related y
91
- */
92
- public RPoint(RPoint p) {
93
- this.x = p.x;
94
- this.y = p.y;
95
- }
96
-
97
- /**
98
- * @invisible
99
- */
100
- float getX() {
101
- return this.x;
102
- }
103
-
104
- /**
105
- * @invisible
106
- */
107
- float getY() {
108
- return this.y;
109
- }
110
-
111
- /**
112
- * @invisible
113
- */
114
- void setLocation(float nx, float ny) {
115
- this.x = nx;
116
- this.y = ny;
117
- }
118
-
119
- /**
120
- * Use this to apply a transformation to the point.
121
- *
122
- * @eexample RPoint_transform
123
- * @usage Geometry
124
- * @param m the transformation matrix to be applied
125
- * @related translate ( )
126
- * @related rotate ( )
127
- * @related scale ( )
128
- */
129
- public void transform(RMatrix m) {
130
- float tempx = m.m00 * x + m.m01 * y + m.m02;
131
- float tempy = m.m10 * x + m.m11 * y + m.m12;
132
-
133
- x = tempx;
134
- y = tempy;
135
- }
136
-
137
- /**
138
- * Apply a translation to the point.
139
- *
140
- * @eexample RPoint_translate
141
- * @usage Geometry
142
- * @param tx the coefficient of x translation
143
- * @param ty the coefficient of y translation
144
- * @related transform ( )
145
- * @related rotate ( )
146
- * @related scale ( )
147
- */
148
- public void translate(float tx, float ty) {
149
- x += tx;
150
- y += ty;
151
- }
152
-
153
- /**
154
- * Apply a translation to the point.
155
- *
156
- * @eexample RPoint_translate
157
- * @usage Geometry
158
- * @param t the translation vector to be applied
159
- * @related transform ( )
160
- * @related rotate ( )
161
- * @related scale ( )
162
- */
163
- public void translate(RPoint t) {
164
- x += t.x;
165
- y += t.y;
166
- }
167
-
168
- /**
169
- * Apply a rotation to the point, given the angle and optionally the
170
- * coordinates of the center of rotation.
171
- *
172
- * @eexample RPoint_rotate
173
- * @usage Geometry
174
- * @param angle the angle of rotation to be applied
175
- * @param vx the x coordinate of the center of rotation
176
- * @param vy the y coordinate of the center of rotation
177
- * @related transform ( )
178
- * @related translate ( )
179
- * @related scale ( )
180
- */
181
- public void rotate(float angle, float vx, float vy) {
182
- float c = (float) Math.cos(angle);
183
- float s = (float) Math.sin(angle);
184
-
185
- x -= vx;
186
- y -= vy;
187
-
188
- float tempx = x;
189
- float tempy = y;
190
-
191
- x = tempx * c - tempy * s;
192
- y = tempx * s + tempy * c;
193
-
194
- x += vx;
195
- y += vy;
196
- }
197
-
198
- public void rotate(float angle) {
199
- float c = (float) Math.cos(angle);
200
- float s = (float) Math.sin(angle);
201
-
202
- float tempx = x;
203
- float tempy = y;
204
-
205
- x = tempx * c - tempy * s;
206
- y = tempx * s + tempy * c;
207
- }
208
-
209
- /**
210
- * Apply a rotation to the point, given the angle and optionally the point
211
- * of the center of rotation.
212
- *
213
- * @eexample RPoint_rotate
214
- * @usage Geometry
215
- * @param angle the angle of rotation to be applied
216
- * @param v the position vector of the center of rotation
217
- * @related transform ( )
218
- * @related translate ( )
219
- * @related scale ( )
220
- */
221
- public void rotate(float angle, RPoint v) {
222
- float c = (float) Math.cos(angle);
223
- float s = (float) Math.sin(angle);
224
-
225
- x -= v.x;
226
- y -= v.y;
227
-
228
- float tempx = x;
229
- float tempy = y;
230
-
231
- x = tempx * c - tempy * s;
232
- y = tempx * s + tempy * c;
233
-
234
- x += v.x;
235
- y += v.y;
236
- }
237
-
238
- /**
239
- * Apply a scaling to the point, given the scaling factors.
240
- *
241
- * @eexample RPoint_scale
242
- * @usage Geometry
243
- * @param sx the scaling coefficient over the x axis
244
- * @param sy the scaling coefficient over the y axis
245
- * @related transform ( )
246
- * @related translate ( )
247
- * @related rotate ( )
248
- */
249
- public void scale(float sx, float sy) {
250
- x *= sx;
251
- y *= sy;
252
- }
253
-
254
- /**
255
- * Apply a scaling to the point, given a scaling factor.
256
- *
257
- * @eexample RPoint_scale
258
- * @usage Geometry
259
- * @param s the scaling coefficient for a uniform scaling
260
- * @related transform ( )
261
- * @related translate ( )
262
- * @related rotate ( )
263
- */
264
- public void scale(float s) {
265
- x *= s;
266
- y *= s;
267
- }
268
-
269
- /**
270
- * Apply a scaling to the point, given a scaling vector.
271
- *
272
- * @eexample RPoint_scale
273
- * @usage Geometry
274
- * @param s the scaling vector
275
- * @related transform ( )
276
- * @related translate ( )
277
- * @related rotate ( )
278
- */
279
- public void scale(RPoint s) {
280
- x *= s.x;
281
- y *= s.y;
282
- }
283
-
284
- /**
285
- * Use this to normalize the point. This means that after applying, it's
286
- * norm will be equal to 1.
287
- *
288
- * @eexample RPoint_normalize
289
- * @usage Geometry
290
- * @related transform ( )
291
- * @related translate ( )
292
- * @related rotate ( )
293
- * @related scale ( )
294
- */
295
- public void normalize() {
296
- float norma = norm();
297
- if (norma != 0) {
298
- scale(1 / norma);
299
- }
300
- }
301
-
302
- /**
303
- * Use this to subtract a vector from this point.
304
- *
305
- * @eexample RPoint_sub
306
- * @usage Geometry
307
- * @param p the vector to substract
308
- * @related add ( )
309
- * @related mult ( )
310
- * @related cross ( )
311
- */
312
- public void sub(RPoint p) {
313
- x -= p.x;
314
- y -= p.y;
315
- }
316
-
317
- /**
318
- * Use this to add a vector to this point.
319
- *
320
- * @eexample RPoint_add
321
- * @usage Geometry
322
- * @param p the vector to add
323
- * @related sub ( )
324
- * @related mult ( )
325
- * @related cross ( )
326
- */
327
- public void add(RPoint p) {
328
- x += p.x;
329
- y += p.y;
330
- }
331
-
332
- /**
333
- * Use this to multiply a vector to this point. This returns a float
334
- * corresponding to the scalar product of both vectors.
335
- *
336
- * @eexample RPoint_mult
337
- * @usage Geometry
338
- * @param p the vector to multiply
339
- * @return float, the result of the scalar product
340
- * @related add ( )
341
- * @related sub ( )
342
- * @related cross ( )
343
- */
344
- public float mult(RPoint p) {
345
- return (x * p.x + y * p.y);
346
- }
347
-
348
- /**
349
- * Use this to perform a cross product of the point with another point. This
350
- * returns a RPoint corresponding to the cross product of both vectors.
351
- *
352
- * @eexample RPoint_cross
353
- * @usage Geometry
354
- * @param p the vector to perform the cross product with
355
- * @return RPoint, the resulting vector of the cross product
356
- * @related add ( )
357
- * @related sub ( )
358
- * @related mult ( )
359
- */
360
- public RPoint cross(RPoint p) {
361
- return new RPoint(x * p.y - p.x * y, y * p.x - p.y * x);
362
- }
363
-
364
- /**
365
- * Use this to obtain the norm of the point.
366
- *
367
- * @eexample RPoint_norm
368
- * @usage Geometry
369
- * @return float, the norm of the point
370
- * @related angle ( )
371
- */
372
- public float norm() {
373
- return (float) Math.sqrt(mult(this));
374
- }
375
-
376
- /**
377
- * Use this to obtain the square norm of the point.
378
- *
379
- * @eexample RPoint_norm
380
- * @usage Geometry
381
- * @return float, the norm of the point
382
- * @related angle ( )
383
- */
384
- public float sqrnorm() {
385
- return (float) mult(this);
386
- }
387
-
388
- /**
389
- * Use this to obtain the angle between the vector and another vector
390
- *
391
- * @eexample RPoint_angle
392
- * @usage Geometry
393
- * @param p the vector relative to which we want to evaluate the angle
394
- * @return float, the angle between the two vectors
395
- * @related norm ( )
396
- */
397
- public float angle(RPoint p) {
398
- float normp = p.norm();
399
- float normthis = norm();
400
- return (float) Math.acos(mult(p) / (normp * normthis));
401
- }
402
-
403
- /**
404
- * Use this to obtain the distance between the vector and another vector
405
- *
406
- * @eexample RPoint_dist
407
- * @usage Geometry
408
- * @param p the vector relative to which we want to evaluate the distance
409
- * @return float, the distance between the two vectors
410
- * @related norm ( )
411
- */
412
- public float dist(RPoint p) {
413
- return (float) Math.hypot(p.x - this.x, p.y - this.y);
414
- }
415
-
416
- public void print() {
417
- System.out.print("(" + x + "," + y + ")\n");
32
+ /**
33
+ * The x coordinate of the point.
34
+ *
35
+ RPoint_x
36
+ * Geometry
37
+ * y
38
+ */
39
+ public float x;
40
+
41
+ /**
42
+ * The y coordinate of the point.
43
+ *
44
+ RPoint_y
45
+ * Geometry
46
+ * x
47
+ */
48
+ public float y;
49
+
50
+ /**
51
+ * Create a new point, given the coordinates.
52
+ *
53
+ RPoint_constructor
54
+ * Geometry
55
+ * @param x the x coordinate of the new point
56
+ * @param y the y coordinate of the new point
57
+ * x
58
+ * y
59
+ */
60
+ public RPoint(float x, float y) {
61
+ this.x = x;
62
+ this.y = y;
63
+ }
64
+
65
+ public RPoint(double x, double y) {
66
+ this.x = (float) x;
67
+ this.y = (float) y;
68
+ }
69
+
70
+ /**
71
+ * Create a new point at (0, 0).
72
+ *
73
+ RPoint_constructor
74
+ * Geometry
75
+ * x
76
+ * y
77
+ */
78
+ public RPoint() {
79
+ x = 0;
80
+ y = 0;
81
+ }
82
+
83
+ /**
84
+ * Copy a point.
85
+ *
86
+ RPoint_constructor
87
+ * Geometry
88
+ * @param p the point we wish to make a copy of
89
+ * x
90
+ * y
91
+ */
92
+ public RPoint(RPoint p) {
93
+ this.x = p.x;
94
+ this.y = p.y;
95
+ }
96
+
97
+ /**
98
+ *
99
+ */
100
+ float getX() {
101
+ return this.x;
102
+ }
103
+
104
+ /**
105
+ *
106
+ */
107
+ float getY() {
108
+ return this.y;
109
+ }
110
+
111
+ /**
112
+ *
113
+ */
114
+ void setLocation(float nx, float ny) {
115
+ this.x = nx;
116
+ this.y = ny;
117
+ }
118
+
119
+ /**
120
+ * Use this to apply a transformation to the point.
121
+ *
122
+ RPoint_transform
123
+ * Geometry
124
+ * @param m the transformation matrix to be applied
125
+ * translate ( )
126
+ * rotate ( )
127
+ * scale ( )
128
+ */
129
+ public void transform(RMatrix m) {
130
+ float tempx = m.m00 * x + m.m01 * y + m.m02;
131
+ float tempy = m.m10 * x + m.m11 * y + m.m12;
132
+
133
+ x = tempx;
134
+ y = tempy;
135
+ }
136
+
137
+ /**
138
+ * Apply a translation to the point.
139
+ *
140
+ RPoint_translate
141
+ * Geometry
142
+ * @param tx the coefficient of x translation
143
+ * @param ty the coefficient of y translation
144
+ * transform ( )
145
+ * rotate ( )
146
+ * scale ( )
147
+ */
148
+ public void translate(float tx, float ty) {
149
+ x += tx;
150
+ y += ty;
151
+ }
152
+
153
+ /**
154
+ * Apply a translation to the point.
155
+ *
156
+ RPoint_translate
157
+ * Geometry
158
+ * @param t the translation vector to be applied
159
+ * transform ( )
160
+ * rotate ( )
161
+ * scale ( )
162
+ */
163
+ public void translate(RPoint t) {
164
+ x += t.x;
165
+ y += t.y;
166
+ }
167
+
168
+ /**
169
+ * Apply a rotation to the point, given the angle and optionally the
170
+ * coordinates of the center of rotation.
171
+ *
172
+ RPoint_rotate
173
+ * Geometry
174
+ * @param angle the angle of rotation to be applied
175
+ * @param vx the x coordinate of the center of rotation
176
+ * @param vy the y coordinate of the center of rotation
177
+ * transform ( )
178
+ * translate ( )
179
+ * scale ( )
180
+ */
181
+ public void rotate(float angle, float vx, float vy) {
182
+ float c = (float) Math.cos(angle);
183
+ float s = (float) Math.sin(angle);
184
+
185
+ x -= vx;
186
+ y -= vy;
187
+
188
+ float tempx = x;
189
+ float tempy = y;
190
+
191
+ x = tempx * c - tempy * s;
192
+ y = tempx * s + tempy * c;
193
+
194
+ x += vx;
195
+ y += vy;
196
+ }
197
+
198
+ public void rotate(float angle) {
199
+ float c = (float) Math.cos(angle);
200
+ float s = (float) Math.sin(angle);
201
+
202
+ float tempx = x;
203
+ float tempy = y;
204
+
205
+ x = tempx * c - tempy * s;
206
+ y = tempx * s + tempy * c;
207
+ }
208
+
209
+ /**
210
+ * Apply a rotation to the point, given the angle and optionally the point of
211
+ * the center of rotation.
212
+ *
213
+ RPoint_rotate
214
+ * Geometry
215
+ * @param angle the angle of rotation to be applied
216
+ * @param v the position vector of the center of rotation
217
+ * transform ( )
218
+ * translate ( )
219
+ * scale ( )
220
+ */
221
+ public void rotate(float angle, RPoint v) {
222
+ float c = (float) Math.cos(angle);
223
+ float s = (float) Math.sin(angle);
224
+
225
+ x -= v.x;
226
+ y -= v.y;
227
+
228
+ float tempx = x;
229
+ float tempy = y;
230
+
231
+ x = tempx * c - tempy * s;
232
+ y = tempx * s + tempy * c;
233
+
234
+ x += v.x;
235
+ y += v.y;
236
+ }
237
+
238
+ /**
239
+ * Apply a scaling to the point, given the scaling factors.
240
+ *
241
+ RPoint_scale
242
+ * Geometry
243
+ * @param sx the scaling coefficient over the x axis
244
+ * @param sy the scaling coefficient over the y axis
245
+ * transform ( )
246
+ * translate ( )
247
+ * rotate ( )
248
+ */
249
+ public void scale(float sx, float sy) {
250
+ x *= sx;
251
+ y *= sy;
252
+ }
253
+
254
+ /**
255
+ * Apply a scaling to the point, given a scaling factor.
256
+ *
257
+ RPoint_scale
258
+ * Geometry
259
+ * @param s the scaling coefficient for a uniform scaling
260
+ * transform ( )
261
+ * translate ( )
262
+ * rotate ( )
263
+ */
264
+ public void scale(float s) {
265
+ x *= s;
266
+ y *= s;
267
+ }
268
+
269
+ /**
270
+ * Apply a scaling to the point, given a scaling vector.
271
+ *
272
+ RPoint_scale
273
+ * Geometry
274
+ * @param s the scaling vector
275
+ * transform ( )
276
+ * translate ( )
277
+ * rotate ( )
278
+ */
279
+ public void scale(RPoint s) {
280
+ x *= s.x;
281
+ y *= s.y;
282
+ }
283
+
284
+ /**
285
+ * Use this to normalize the point. This means that after applying, it's norm
286
+ * will be equal to 1.
287
+ *
288
+ RPoint_normalize
289
+ * Geometry
290
+ * transform ( )
291
+ * translate ( )
292
+ * rotate ( )
293
+ * scale ( )
294
+ */
295
+ public void normalize() {
296
+ float norma = norm();
297
+ if (norma != 0) {
298
+ scale(1 / norma);
418
299
  }
300
+ }
301
+
302
+ /**
303
+ * Use this to subtract a vector from this point.
304
+ *
305
+ RPoint_sub
306
+ * Geometry
307
+ * @param p the vector to substract
308
+ * add ( )
309
+ * mult ( )
310
+ * cross ( )
311
+ */
312
+ public void sub(RPoint p) {
313
+ x -= p.x;
314
+ y -= p.y;
315
+ }
316
+
317
+ /**
318
+ * Use this to add a vector to this point.
319
+ *
320
+ RPoint_add
321
+ * Geometry
322
+ * @param p the vector to add
323
+ * sub ( )
324
+ * mult ( )
325
+ * cross ( )
326
+ */
327
+ public void add(RPoint p) {
328
+ x += p.x;
329
+ y += p.y;
330
+ }
331
+
332
+ /**
333
+ * Use this to multiply a vector to this point. This returns a float
334
+ * corresponding to the scalar product of both vectors.
335
+ *
336
+ RPoint_mult
337
+ * Geometry
338
+ * @param p the vector to multiply
339
+ * @return float, the result of the scalar product
340
+ * add ( )
341
+ * sub ( )
342
+ * cross ( )
343
+ */
344
+ public float mult(RPoint p) {
345
+ return (x * p.x + y * p.y);
346
+ }
347
+
348
+ /**
349
+ * Use this to perform a cross product of the point with another point. This
350
+ * returns a RPoint corresponding to the cross product of both vectors.
351
+ *
352
+ RPoint_cross
353
+ * Geometry
354
+ * @param p the vector to perform the cross product with
355
+ * @return RPoint, the resulting vector of the cross product
356
+ * add ( )
357
+ * sub ( )
358
+ * mult ( )
359
+ */
360
+ public RPoint cross(RPoint p) {
361
+ return new RPoint(x * p.y - p.x * y, y * p.x - p.y * x);
362
+ }
363
+
364
+ /**
365
+ * Use this to obtain the norm of the point.
366
+ *
367
+ RPoint_norm
368
+ * Geometry
369
+ * @return float, the norm of the point
370
+ * angle ( )
371
+ */
372
+ public float norm() {
373
+ return (float) Math.sqrt(mult(this));
374
+ }
375
+
376
+ /**
377
+ * Use this to obtain the square norm of the point.
378
+ *
379
+ RPoint_norm
380
+ * Geometry
381
+ * @return float, the norm of the point
382
+ * angle ( )
383
+ */
384
+ public float sqrnorm() {
385
+ return (float) mult(this);
386
+ }
387
+
388
+ /**
389
+ * Use this to obtain the angle between the vector and another vector
390
+ *
391
+ RPoint_angle
392
+ * Geometry
393
+ * @param p the vector relative to which we want to evaluate the angle
394
+ * @return float, the angle between the two vectors
395
+ * norm ( )
396
+ */
397
+ public float angle(RPoint p) {
398
+ float normp = p.norm();
399
+ float normthis = norm();
400
+ return (float) Math.acos(mult(p) / (normp * normthis));
401
+ }
402
+
403
+ /**
404
+ * Use this to obtain the distance between the vector and another vector
405
+ *
406
+ RPoint_dist
407
+ * Geometry
408
+ * @param p the vector relative to which we want to evaluate the distance
409
+ * @return float, the distance between the two vectors
410
+ * norm ( )
411
+ */
412
+ public float dist(RPoint p) {
413
+ return (float) Math.hypot(p.x - this.x, p.y - this.y);
414
+ }
415
+
416
+ public void print() {
417
+ System.out.print("(" + x + "," + y + ")\n");
418
+ }
419
419
  }