geomerative 0.4.0-java → 2.0.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.mvn/extensions.xml +1 -1
  4. data/.mvn/wrapper/maven-wrapper.properties +1 -1
  5. data/CHANGELOG.md +25 -0
  6. data/COPYING.md +1 -1
  7. data/README.md +4 -2
  8. data/Rakefile +2 -15
  9. data/docs/.gitignore +6 -0
  10. data/docs/_config.yml +30 -0
  11. data/docs/_includes/footer.html +38 -0
  12. data/docs/_includes/head.html +16 -0
  13. data/docs/_includes/header.html +27 -0
  14. data/docs/_includes/icon-github.html +1 -0
  15. data/docs/_includes/icon-github.svg +3 -0
  16. data/docs/_includes/icon-twitter.html +1 -0
  17. data/docs/_includes/icon-twitter.svg +3 -0
  18. data/docs/_includes/navigation.html +24 -0
  19. data/docs/_layouts/default.html +20 -0
  20. data/docs/_layouts/page.html +14 -0
  21. data/docs/_layouts/post.html +15 -0
  22. data/docs/_posts/2015-11-21-getting_started.md +67 -0
  23. data/docs/_posts/2015-11-25-bubbles.md +111 -0
  24. data/docs/_posts/2015-11-26-extra_bright.md +103 -0
  25. data/docs/_posts/2015-11-26-text_merge.md +114 -0
  26. data/docs/_posts/2016-07-06-dymo.md +99 -0
  27. data/docs/_sass/_base.scss +206 -0
  28. data/docs/_sass/_layout.scss +242 -0
  29. data/docs/_sass/_syntax-highlighting.scss +71 -0
  30. data/docs/about.md +12 -0
  31. data/docs/assets/bright.png +0 -0
  32. data/docs/assets/bubbles.png +0 -0
  33. data/docs/assets/design.png +0 -0
  34. data/docs/assets/dymo.png +0 -0
  35. data/docs/assets/favicon.ico +0 -0
  36. data/docs/assets/fred.png +0 -0
  37. data/docs/assets/merge.png +0 -0
  38. data/docs/css/main.scss +38 -0
  39. data/docs/favicon.ico +0 -0
  40. data/docs/feed.xml +30 -0
  41. data/docs/index.html +38 -0
  42. data/examples/README.md +1 -1
  43. data/examples/data/bot1.svg +1 -1
  44. data/examples/data/lion.svg +156 -156
  45. data/examples/data/ruby.svg +1 -1
  46. data/examples/hello_svg_to_pdf.rb +1 -1
  47. data/examples/jruby_merge.rb +1 -1
  48. data/examples/{f_agent.rb → library/f_agent/f_agent.rb} +0 -0
  49. data/examples/{font_agent.rb → library/font_agent/font_agent.rb} +2 -1
  50. data/examples/text_on_geomerative_path.rb +3 -2
  51. data/examples/typo_deform.rb +2 -2
  52. data/examples/typo_extra_bright.rb +1 -1
  53. data/geomerative.gemspec +3 -7
  54. data/lib/geomerative.rb +5 -4
  55. data/lib/geomerative/version.rb +1 -1
  56. data/mvnw +234 -0
  57. data/mvnw.cmd +145 -0
  58. data/pom.rb +19 -18
  59. data/pom.xml +14 -13
  60. data/src/geomerative/FastRClip.java +2050 -2334
  61. data/src/geomerative/RClip.java +2237 -2539
  62. data/src/geomerative/RClosest.java +33 -31
  63. data/src/geomerative/RCommand.java +1750 -1758
  64. data/src/geomerative/RContour.java +290 -292
  65. data/src/geomerative/RFont.java +277 -246
  66. data/src/geomerative/RG.java +722 -727
  67. data/src/geomerative/RGeomElem.java +967 -962
  68. data/src/geomerative/RGroup.java +508 -467
  69. data/src/geomerative/RMatrix.java +304 -289
  70. data/src/geomerative/RMesh.java +241 -229
  71. data/src/geomerative/RPath.java +924 -926
  72. data/src/geomerative/RPoint.java +391 -391
  73. data/src/geomerative/RPolygon.java +1017 -1013
  74. data/src/geomerative/RRectangle.java +43 -52
  75. data/src/geomerative/RSVG.java +480 -516
  76. data/src/geomerative/RShape.java +1767 -1777
  77. data/src/geomerative/RStrip.java +173 -176
  78. data/src/geomerative/RStyle.java +197 -194
  79. data/src/org/apache/batik/svggen/font/Font.java +141 -142
  80. data/src/org/apache/batik/svggen/font/Glyph.java +102 -71
  81. data/src/org/apache/batik/svggen/font/Point.java +12 -12
  82. data/src/org/apache/batik/svggen/font/RandomAccessFileEmulator.java +14 -12
  83. data/src/org/apache/batik/svggen/font/table/ClassDef.java +12 -12
  84. data/src/org/apache/batik/svggen/font/table/ClassDefFormat1.java +27 -24
  85. data/src/org/apache/batik/svggen/font/table/ClassDefFormat2.java +20 -17
  86. data/src/org/apache/batik/svggen/font/table/CmapFormat.java +43 -43
  87. data/src/org/apache/batik/svggen/font/table/CmapFormat0.java +33 -26
  88. data/src/org/apache/batik/svggen/font/table/CmapFormat2.java +25 -20
  89. data/src/org/apache/batik/svggen/font/table/CmapFormat4.java +106 -96
  90. data/src/org/apache/batik/svggen/font/table/CmapFormat6.java +36 -32
  91. data/src/org/apache/batik/svggen/font/table/CmapIndexEntry.java +69 -49
  92. data/src/org/apache/batik/svggen/font/table/CmapTable.java +50 -50
  93. data/src/org/apache/batik/svggen/font/table/Coverage.java +19 -19
  94. data/src/org/apache/batik/svggen/font/table/CoverageFormat1.java +30 -27
  95. data/src/org/apache/batik/svggen/font/table/CoverageFormat2.java +26 -24
  96. data/src/org/apache/batik/svggen/font/table/CvtTable.java +16 -16
  97. data/src/org/apache/batik/svggen/font/table/Device.java +32 -32
  98. data/src/org/apache/batik/svggen/font/table/DirectoryEntry.java +39 -39
  99. data/src/org/apache/batik/svggen/font/table/Feature.java +26 -23
  100. data/src/org/apache/batik/svggen/font/table/FeatureList.java +37 -35
  101. data/src/org/apache/batik/svggen/font/table/FeatureRecord.java +22 -22
  102. data/src/org/apache/batik/svggen/font/table/FeatureTags.java +4 -3
  103. data/src/org/apache/batik/svggen/font/table/FpgmTable.java +9 -9
  104. data/src/org/apache/batik/svggen/font/table/GlyfCompositeComp.java +134 -132
  105. data/src/org/apache/batik/svggen/font/table/GlyfCompositeDescript.java +123 -122
  106. data/src/org/apache/batik/svggen/font/table/GlyfDescript.java +44 -44
  107. data/src/org/apache/batik/svggen/font/table/GlyfSimpleDescript.java +110 -109
  108. data/src/org/apache/batik/svggen/font/table/GlyfTable.java +46 -46
  109. data/src/org/apache/batik/svggen/font/table/GlyphDescription.java +25 -13
  110. data/src/org/apache/batik/svggen/font/table/GposTable.java +26 -23
  111. data/src/org/apache/batik/svggen/font/table/GsubTable.java +85 -82
  112. data/src/org/apache/batik/svggen/font/table/HeadTable.java +131 -131
  113. data/src/org/apache/batik/svggen/font/table/HheaTable.java +80 -80
  114. data/src/org/apache/batik/svggen/font/table/HmtxTable.java +50 -49
  115. data/src/org/apache/batik/svggen/font/table/KernSubtable.java +29 -27
  116. data/src/org/apache/batik/svggen/font/table/KernSubtableFormat0.java +35 -32
  117. data/src/org/apache/batik/svggen/font/table/KernSubtableFormat2.java +28 -26
  118. data/src/org/apache/batik/svggen/font/table/KernTable.java +36 -31
  119. data/src/org/apache/batik/svggen/font/table/KerningPair.java +27 -23
  120. data/src/org/apache/batik/svggen/font/table/LangSys.java +28 -26
  121. data/src/org/apache/batik/svggen/font/table/LangSysRecord.java +22 -22
  122. data/src/org/apache/batik/svggen/font/table/Ligature.java +24 -24
  123. data/src/org/apache/batik/svggen/font/table/LigatureSet.java +24 -24
  124. data/src/org/apache/batik/svggen/font/table/LigatureSubst.java +9 -9
  125. data/src/org/apache/batik/svggen/font/table/LigatureSubstFormat1.java +30 -30
  126. data/src/org/apache/batik/svggen/font/table/LocaTable.java +37 -37
  127. data/src/org/apache/batik/svggen/font/table/Lookup.java +41 -40
  128. data/src/org/apache/batik/svggen/font/table/LookupList.java +34 -34
  129. data/src/org/apache/batik/svggen/font/table/LookupSubtableFactory.java +7 -5
  130. data/src/org/apache/batik/svggen/font/table/MaxpTable.java +96 -96
  131. data/src/org/apache/batik/svggen/font/table/NameRecord.java +64 -65
  132. data/src/org/apache/batik/svggen/font/table/NameTable.java +33 -33
  133. data/src/org/apache/batik/svggen/font/table/Os2Table.java +196 -196
  134. data/src/org/apache/batik/svggen/font/table/Panose.java +14 -12
  135. data/src/org/apache/batik/svggen/font/table/PostTable.java +338 -338
  136. data/src/org/apache/batik/svggen/font/table/PrepTable.java +9 -9
  137. data/src/org/apache/batik/svggen/font/table/Program.java +15 -15
  138. data/src/org/apache/batik/svggen/font/table/RangeRecord.java +26 -25
  139. data/src/org/apache/batik/svggen/font/table/Script.java +38 -38
  140. data/src/org/apache/batik/svggen/font/table/ScriptList.java +42 -42
  141. data/src/org/apache/batik/svggen/font/table/ScriptRecord.java +22 -22
  142. data/src/org/apache/batik/svggen/font/table/ScriptTags.java +2 -1
  143. data/src/org/apache/batik/svggen/font/table/SingleSubst.java +15 -16
  144. data/src/org/apache/batik/svggen/font/table/SingleSubstFormat1.java +33 -33
  145. data/src/org/apache/batik/svggen/font/table/SingleSubstFormat2.java +32 -32
  146. data/src/org/apache/batik/svggen/font/table/Table.java +171 -170
  147. data/src/org/apache/batik/svggen/font/table/TableDirectory.java +55 -55
  148. data/src/org/apache/batik/svggen/font/table/TableFactory.java +92 -93
  149. metadata +47 -30
  150. data/.travis.yml +0 -14
@@ -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
  }