propane 3.1.0.pre-java → 3.2.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.
- checksums.yaml +4 -4
- data/.mvn/wrapper/maven-wrapper.properties +1 -0
- data/CHANGELOG.md +1 -5
- data/README.md +23 -12
- data/Rakefile +23 -12
- data/lib/propane/helpers/version_error.rb +6 -0
- data/lib/propane/runner.rb +12 -0
- data/lib/propane/version.rb +1 -1
- data/library/slider/slider.rb +1 -1
- data/mvnw +234 -0
- data/mvnw.cmd +145 -0
- data/pom.xml +28 -27
- data/propane.gemspec +2 -2
- data/src/main/java/japplemenubar/JAppleMenuBar.java +41 -47
- data/src/main/java/monkstone/ColorUtil.java +1 -1
- data/src/main/java/monkstone/MathToolModule.java +12 -11
- data/src/main/java/monkstone/PropaneLibrary.java +9 -10
- data/src/main/java/monkstone/core/LibraryProxy.java +124 -113
- data/src/main/java/monkstone/fastmath/Deglut.java +86 -89
- data/src/main/java/monkstone/filechooser/Chooser.java +7 -13
- data/src/main/java/monkstone/noise/SimplexNoise.java +0 -1
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +4 -4
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +9 -9
- data/src/main/java/monkstone/slider/SimpleSlider.java +0 -9
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +11 -13
- data/src/main/java/monkstone/slider/Slider.java +1 -1
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/slider/WheelHandler.java +8 -9
- data/src/main/java/monkstone/vecmath/AppRender.java +2 -2
- data/src/main/java/monkstone/vecmath/ShapeRender.java +2 -2
- data/src/main/java/monkstone/vecmath/package-info.java +2 -2
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +2 -2
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
- data/src/main/java/monkstone/videoevent/VideoInterface.java +11 -5
- data/src/main/java/monkstone/videoevent/package-info.java +2 -2
- data/src/main/java/processing/awt/PGraphicsJava2D.java +1742 -2243
- data/src/main/java/processing/awt/PShapeJava2D.java +268 -270
- data/src/main/java/processing/awt/PSurfaceAWT.java +821 -920
- data/src/main/java/processing/core/DesktopHandler.java +94 -0
- data/src/main/java/processing/core/PApplet.java +14170 -14082
- data/src/main/java/processing/core/PConstants.java +447 -473
- data/src/main/java/processing/core/PFont.java +867 -873
- data/src/main/java/processing/core/PGraphics.java +7193 -7428
- data/src/main/java/processing/core/PImage.java +3051 -3117
- data/src/main/java/processing/core/PMatrix.java +159 -172
- data/src/main/java/processing/core/PMatrix2D.java +403 -444
- data/src/main/java/processing/core/PMatrix3D.java +735 -749
- data/src/main/java/processing/core/PShape.java +2651 -2793
- data/src/main/java/processing/core/PShapeOBJ.java +415 -422
- data/src/main/java/processing/core/PShapeSVG.java +1466 -1475
- data/src/main/java/processing/core/PStyle.java +37 -40
- data/src/main/java/processing/core/PSurface.java +98 -103
- data/src/main/java/processing/core/PSurfaceNone.java +208 -236
- data/src/main/java/processing/core/PVector.java +961 -990
- data/src/main/java/processing/data/DoubleDict.java +709 -753
- data/src/main/java/processing/data/DoubleList.java +695 -748
- data/src/main/java/processing/data/FloatDict.java +702 -746
- data/src/main/java/processing/data/FloatList.java +697 -751
- data/src/main/java/processing/data/IntDict.java +673 -718
- data/src/main/java/processing/data/IntList.java +633 -699
- data/src/main/java/processing/data/JSONArray.java +873 -931
- data/src/main/java/processing/data/JSONObject.java +1165 -1262
- data/src/main/java/processing/data/JSONTokener.java +341 -351
- data/src/main/java/processing/data/LongDict.java +662 -707
- data/src/main/java/processing/data/LongList.java +634 -700
- data/src/main/java/processing/data/Sort.java +41 -37
- data/src/main/java/processing/data/StringDict.java +486 -522
- data/src/main/java/processing/data/StringList.java +580 -624
- data/src/main/java/processing/data/Table.java +3508 -3686
- data/src/main/java/processing/data/TableRow.java +183 -182
- data/src/main/java/processing/data/XML.java +883 -957
- data/src/main/java/processing/event/Event.java +66 -87
- data/src/main/java/processing/event/KeyEvent.java +41 -48
- data/src/main/java/processing/event/MouseEvent.java +93 -103
- data/src/main/java/processing/event/TouchEvent.java +6 -10
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +5 -69
- data/src/main/java/processing/javafx/PSurfaceFX.java +2 -7
- data/src/main/java/processing/opengl/FontTexture.java +270 -290
- data/src/main/java/processing/opengl/FrameBuffer.java +363 -375
- data/src/main/java/processing/opengl/LinePath.java +500 -543
- data/src/main/java/processing/opengl/LineStroker.java +582 -593
- data/src/main/java/processing/opengl/PGL.java +2881 -2904
- data/src/main/java/processing/opengl/PGraphics2D.java +315 -408
- data/src/main/java/processing/opengl/PGraphics3D.java +72 -107
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12043 -12230
- data/src/main/java/processing/opengl/PJOGL.java +1681 -1745
- data/src/main/java/processing/opengl/PShader.java +1257 -1260
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4599 -4662
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1030 -1047
- data/src/main/java/processing/opengl/Texture.java +1397 -1462
- data/src/main/java/processing/opengl/VertexBuffer.java +55 -57
- data/src/main/resources/icon/icon-1024.png +0 -0
- data/src/main/resources/icon/icon-128.png +0 -0
- data/src/main/resources/icon/icon-16.png +0 -0
- data/src/main/resources/icon/icon-256.png +0 -0
- data/src/main/resources/icon/icon-32.png +0 -0
- data/src/main/resources/icon/icon-48.png +0 -0
- data/src/main/resources/icon/icon-512.png +0 -0
- data/src/main/resources/icon/icon-64.png +0 -0
- data/vendors/Rakefile +1 -1
- metadata +12 -8
- data/src/main/java/processing/core/ThinkDifferent.java +0 -70
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
|
2
|
-
|
|
3
1
|
/*
|
|
4
2
|
Part of the Processing project - http://processing.org
|
|
5
3
|
|
|
@@ -19,190 +17,179 @@
|
|
|
19
17
|
Public License along with this library; if not, write to the
|
|
20
18
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
21
19
|
Boston, MA 02111-1307 USA
|
|
22
|
-
*/
|
|
23
|
-
|
|
20
|
+
*/
|
|
24
21
|
package processing.core;
|
|
25
22
|
|
|
26
|
-
|
|
27
23
|
/**
|
|
28
24
|
* A matrix is used to define graphical transformations. PMatrix is the common
|
|
29
25
|
* interface for both the 2D and 3D matrix classes in Processing. A matrix is a
|
|
30
26
|
* grid of numbers, which can be multiplied by a vector to give another vector.
|
|
31
|
-
* Multiplying a point by a particular matrix might translate it, rotate it,
|
|
32
|
-
*
|
|
27
|
+
* Multiplying a point by a particular matrix might translate it, rotate it, or
|
|
28
|
+
* carry out a combination of transformations.
|
|
33
29
|
*
|
|
34
30
|
* Multiplying matrices by each other combines their effects; use the
|
|
35
31
|
* {@code apply} and {@code preApply} methods for this.
|
|
36
32
|
*/
|
|
37
33
|
public interface PMatrix {
|
|
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
|
-
* recommended if you call this many times in draw().
|
|
178
|
-
*/
|
|
179
|
-
public float[] mult(float[] source, float[] target);
|
|
180
|
-
|
|
181
|
-
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Make this an identity matrix. Multiplying by it will have no effect.
|
|
37
|
+
*/
|
|
38
|
+
public void reset();
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns a copy of this PMatrix.
|
|
42
|
+
*/
|
|
43
|
+
public PMatrix get();
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Copies the matrix contents into a float array. If target is null (or not
|
|
47
|
+
* the correct size), a new array will be created.
|
|
48
|
+
*/
|
|
49
|
+
public float[] get(float[] target);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Make this matrix become a copy of src.
|
|
53
|
+
*/
|
|
54
|
+
public void set(PMatrix src);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Set the contents of this matrix to the contents of source. Fills the
|
|
58
|
+
* matrix left-to-right, starting in the top row.
|
|
59
|
+
*/
|
|
60
|
+
public void set(float[] source);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Set the matrix content to this 2D matrix or its 3D equivalent.
|
|
64
|
+
*/
|
|
65
|
+
public void set(float m00, float m01, float m02,
|
|
66
|
+
float m10, float m11, float m12);
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Set the matrix content to the 3D matrix supplied, if this matrix is 3D.
|
|
70
|
+
*/
|
|
71
|
+
public void set(float m00, float m01, float m02, float m03,
|
|
72
|
+
float m10, float m11, float m12, float m13,
|
|
73
|
+
float m20, float m21, float m22, float m23,
|
|
74
|
+
float m30, float m31, float m32, float m33);
|
|
75
|
+
|
|
76
|
+
public void translate(float tx, float ty);
|
|
77
|
+
|
|
78
|
+
public void translate(float tx, float ty, float tz);
|
|
79
|
+
|
|
80
|
+
public void rotate(float angle);
|
|
81
|
+
|
|
82
|
+
public void rotateX(float angle);
|
|
83
|
+
|
|
84
|
+
public void rotateY(float angle);
|
|
85
|
+
|
|
86
|
+
public void rotateZ(float angle);
|
|
87
|
+
|
|
88
|
+
public void rotate(float angle, float v0, float v1, float v2);
|
|
89
|
+
|
|
90
|
+
public void scale(float s);
|
|
91
|
+
|
|
92
|
+
public void scale(float sx, float sy);
|
|
93
|
+
|
|
94
|
+
public void scale(float x, float y, float z);
|
|
95
|
+
|
|
96
|
+
public void shearX(float angle);
|
|
97
|
+
|
|
98
|
+
public void shearY(float angle);
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Multiply this matrix by another.
|
|
102
|
+
*/
|
|
103
|
+
public void apply(PMatrix source);
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Multiply this matrix by another.
|
|
107
|
+
*/
|
|
108
|
+
public void apply(PMatrix2D source);
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Multiply this matrix by another.
|
|
112
|
+
*/
|
|
113
|
+
public void apply(PMatrix3D source);
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Multiply this matrix by another.
|
|
117
|
+
*/
|
|
118
|
+
public void apply(float n00, float n01, float n02,
|
|
119
|
+
float n10, float n11, float n12);
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Multiply this matrix by another.
|
|
123
|
+
*/
|
|
124
|
+
public void apply(float n00, float n01, float n02, float n03,
|
|
125
|
+
float n10, float n11, float n12, float n13,
|
|
126
|
+
float n20, float n21, float n22, float n23,
|
|
127
|
+
float n30, float n31, float n32, float n33);
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Apply another matrix to the left of this one.
|
|
131
|
+
*/
|
|
132
|
+
public void preApply(PMatrix left);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Apply another matrix to the left of this one.
|
|
136
|
+
*/
|
|
137
|
+
public void preApply(PMatrix2D left);
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Apply another matrix to the left of this one. 3D only.
|
|
141
|
+
*/
|
|
142
|
+
public void preApply(PMatrix3D left);
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Apply another matrix to the left of this one.
|
|
146
|
+
*/
|
|
147
|
+
public void preApply(float n00, float n01, float n02,
|
|
148
|
+
float n10, float n11, float n12);
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Apply another matrix to the left of this one. 3D only.
|
|
152
|
+
*/
|
|
153
|
+
public void preApply(float n00, float n01, float n02, float n03,
|
|
154
|
+
float n10, float n11, float n12, float n13,
|
|
155
|
+
float n20, float n21, float n22, float n23,
|
|
156
|
+
float n30, float n31, float n32, float n33);
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Multiply source by this matrix, and return the result. The result will be
|
|
160
|
+
* stored in target if target is non-null, and target will then be the
|
|
161
|
+
* matrix returned. This improves performance if you reuse target, so it's
|
|
162
|
+
* recommended if you call this many times in draw().
|
|
163
|
+
*/
|
|
164
|
+
public PVector mult(PVector source, PVector target);
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Multiply a multi-element vector against this matrix. Supplying and
|
|
168
|
+
* recycling a target array improves performance, so it's recommended if you
|
|
169
|
+
* call this many times in draw().
|
|
170
|
+
*/
|
|
171
|
+
public float[] mult(float[] source, float[] target);
|
|
172
|
+
|
|
182
173
|
// public float multX(float x, float y);
|
|
183
174
|
// public float multY(float x, float y);
|
|
184
|
-
|
|
185
175
|
// public float multX(float x, float y, float z);
|
|
186
176
|
// public float multY(float x, float y, float z);
|
|
187
177
|
// public float multZ(float x, float y, float z);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
* @return the determinant of the matrix
|
|
206
|
-
*/
|
|
207
|
-
public float determinant();
|
|
178
|
+
/**
|
|
179
|
+
* Transpose this matrix; rows become columns and columns rows.
|
|
180
|
+
*/
|
|
181
|
+
public void transpose();
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Invert this matrix. Will not necessarily succeed, because some matrices
|
|
185
|
+
* map more than one point to the same image point, and so are irreversible.
|
|
186
|
+
*
|
|
187
|
+
* @return true if successful
|
|
188
|
+
*/
|
|
189
|
+
public boolean invert();
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @return the determinant of the matrix
|
|
193
|
+
*/
|
|
194
|
+
public float determinant();
|
|
208
195
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
|
2
|
-
|
|
3
1
|
/*
|
|
4
2
|
Part of the Processing project - http://processing.org
|
|
5
3
|
|
|
@@ -19,516 +17,477 @@
|
|
|
19
17
|
Public License along with this library; if not, write to the
|
|
20
18
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
21
19
|
Boston, MA 02111-1307 USA
|
|
22
|
-
*/
|
|
23
|
-
|
|
20
|
+
*/
|
|
24
21
|
package processing.core;
|
|
25
22
|
|
|
26
|
-
|
|
27
23
|
/**
|
|
28
|
-
* 3x2 affine matrix implementation.
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* a vector (x, y) in {@code mult()}.
|
|
24
|
+
* 3x2 affine matrix implementation. Matrices are used to describe a
|
|
25
|
+
* transformation; see {@link PMatrix} for a general description. This matrix
|
|
26
|
+
* looks like the following when multiplying a vector (x, y) in {@code mult()}.
|
|
32
27
|
* <pre>
|
|
33
28
|
* [m00 m01 m02][x] [m00*x + m01*y + m02*1] [x']
|
|
34
29
|
* [m10 m11 m12][y] = [m10*x + m11*y + m12*1] = [y']
|
|
35
|
-
* [ 0 0 1 ][1] [ 0*x + 0*y + 1*1 ] [ 1]</pre>
|
|
36
|
-
*
|
|
37
|
-
*
|
|
30
|
+
* [ 0 0 1 ][1] [ 0*x + 0*y + 1*1 ] [ 1]</pre> (x', y') is returned. The values
|
|
31
|
+
* in the matrix determine the transformation. They are modified by the various
|
|
32
|
+
* transformation functions.
|
|
38
33
|
*/
|
|
39
34
|
public class PMatrix2D implements PMatrix {
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Create a new matrix, set to the identity matrix.
|
|
47
|
-
*/
|
|
48
|
-
public PMatrix2D() {
|
|
49
|
-
reset();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
public PMatrix2D(float m00, float m01, float m02,
|
|
54
|
-
float m10, float m11, float m12) {
|
|
55
|
-
set(m00, m01, m02,
|
|
56
|
-
m10, m11, m12);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
public PMatrix2D(PMatrix matrix) {
|
|
61
|
-
set(matrix);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
public void reset() {
|
|
66
|
-
set(1, 0, 0,
|
|
67
|
-
0, 1, 0);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Returns a copy of this PMatrix.
|
|
73
|
-
*/
|
|
74
|
-
public PMatrix2D get() {
|
|
75
|
-
PMatrix2D outgoing = new PMatrix2D();
|
|
76
|
-
outgoing.set(this);
|
|
77
|
-
return outgoing;
|
|
78
|
-
}
|
|
36
|
+
public float m00, m01, m02;
|
|
37
|
+
public float m10, m11, m12;
|
|
79
38
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*/
|
|
86
|
-
public float[] get(float[] target) {
|
|
87
|
-
if ((target == null) || (target.length != 6)) {
|
|
88
|
-
target = new float[6];
|
|
39
|
+
/**
|
|
40
|
+
* Create a new matrix, set to the identity matrix.
|
|
41
|
+
*/
|
|
42
|
+
public PMatrix2D() {
|
|
43
|
+
reset();
|
|
89
44
|
}
|
|
90
|
-
target[0] = m00;
|
|
91
|
-
target[1] = m01;
|
|
92
|
-
target[2] = m02;
|
|
93
|
-
|
|
94
|
-
target[3] = m10;
|
|
95
|
-
target[4] = m11;
|
|
96
|
-
target[5] = m12;
|
|
97
|
-
|
|
98
|
-
return target;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
45
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
public void set(PMatrix matrix) {
|
|
107
|
-
if (matrix instanceof PMatrix2D) {
|
|
108
|
-
PMatrix2D src = (PMatrix2D) matrix;
|
|
109
|
-
set(src.m00, src.m01, src.m02,
|
|
110
|
-
src.m10, src.m11, src.m12);
|
|
111
|
-
} else {
|
|
112
|
-
throw new IllegalArgumentException("PMatrix2D.set() only accepts PMatrix2D objects.");
|
|
46
|
+
public PMatrix2D(float m00, float m01, float m02,
|
|
47
|
+
float m10, float m11, float m12) {
|
|
48
|
+
set(m00, m01, m02,
|
|
49
|
+
m10, m11, m12);
|
|
113
50
|
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Unavailable in 2D. Does nothing.
|
|
119
|
-
*/
|
|
120
|
-
public void set(PMatrix3D src) {
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
public void set(float[] source) {
|
|
125
|
-
m00 = source[0];
|
|
126
|
-
m01 = source[1];
|
|
127
|
-
m02 = source[2];
|
|
128
|
-
|
|
129
|
-
m10 = source[3];
|
|
130
|
-
m11 = source[4];
|
|
131
|
-
m12 = source[5];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Sets the matrix content.
|
|
137
|
-
*/
|
|
138
|
-
public void set(float m00, float m01, float m02,
|
|
139
|
-
float m10, float m11, float m12) {
|
|
140
|
-
this.m00 = m00; this.m01 = m01; this.m02 = m02;
|
|
141
|
-
this.m10 = m10; this.m11 = m11; this.m12 = m12;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Unavailable in 2D. Does nothing.
|
|
147
|
-
*/
|
|
148
|
-
public void set(float m00, float m01, float m02, float m03,
|
|
149
|
-
float m10, float m11, float m12, float m13,
|
|
150
|
-
float m20, float m21, float m22, float m23,
|
|
151
|
-
float m30, float m31, float m32, float m33) {
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
public void translate(float tx, float ty) {
|
|
157
|
-
m02 = tx*m00 + ty*m01 + m02;
|
|
158
|
-
m12 = tx*m10 + ty*m11 + m12;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Unavailable in 2D.
|
|
164
|
-
* @throws IllegalArgumentException
|
|
165
|
-
*/
|
|
166
|
-
public void translate(float x, float y, float z) {
|
|
167
|
-
throw new IllegalArgumentException("Cannot use translate(x, y, z) on a PMatrix2D.");
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// Implementation roughly based on AffineTransform.
|
|
172
|
-
public void rotate(float angle) {
|
|
173
|
-
float s = sin(angle);
|
|
174
|
-
float c = cos(angle);
|
|
175
|
-
|
|
176
|
-
float temp1 = m00;
|
|
177
|
-
float temp2 = m01;
|
|
178
|
-
m00 = c * temp1 + s * temp2;
|
|
179
|
-
m01 = -s * temp1 + c * temp2;
|
|
180
|
-
temp1 = m10;
|
|
181
|
-
temp2 = m11;
|
|
182
|
-
m10 = c * temp1 + s * temp2;
|
|
183
|
-
m11 = -s * temp1 + c * temp2;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Unavailable in 2D.
|
|
189
|
-
* @throws IllegalArgumentException
|
|
190
|
-
*/
|
|
191
|
-
public void rotateX(float angle) {
|
|
192
|
-
throw new IllegalArgumentException("Cannot use rotateX() on a PMatrix2D.");
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Unavailable in 2D.
|
|
198
|
-
* @throws IllegalArgumentException
|
|
199
|
-
*/
|
|
200
|
-
public void rotateY(float angle) {
|
|
201
|
-
throw new IllegalArgumentException("Cannot use rotateY() on a PMatrix2D.");
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
public void rotateZ(float angle) {
|
|
206
|
-
rotate(angle);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Unavailable in 2D.
|
|
212
|
-
* @throws IllegalArgumentException
|
|
213
|
-
*/
|
|
214
|
-
public void rotate(float angle, float v0, float v1, float v2) {
|
|
215
|
-
throw new IllegalArgumentException("Cannot use this version of rotate() on a PMatrix2D.");
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
public void scale(float s) {
|
|
220
|
-
scale(s, s);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
public void scale(float sx, float sy) {
|
|
225
|
-
m00 *= sx; m01 *= sy;
|
|
226
|
-
m10 *= sx; m11 *= sy;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Unavailable in 2D.
|
|
232
|
-
* @throws IllegalArgumentException
|
|
233
|
-
*/
|
|
234
|
-
public void scale(float x, float y, float z) {
|
|
235
|
-
throw new IllegalArgumentException("Cannot use this version of scale() on a PMatrix2D.");
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
public void shearX(float angle) {
|
|
240
|
-
apply(1, 0, 1, tan(angle), 0, 0);
|
|
241
|
-
}
|
|
242
51
|
|
|
52
|
+
public PMatrix2D(PMatrix matrix) {
|
|
53
|
+
set(matrix);
|
|
54
|
+
}
|
|
243
55
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
56
|
+
public void reset() {
|
|
57
|
+
set(1, 0, 0,
|
|
58
|
+
0, 1, 0);
|
|
59
|
+
}
|
|
247
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Returns a copy of this PMatrix.
|
|
63
|
+
*/
|
|
64
|
+
public PMatrix2D get() {
|
|
65
|
+
PMatrix2D outgoing = new PMatrix2D();
|
|
66
|
+
outgoing.set(this);
|
|
67
|
+
return outgoing;
|
|
68
|
+
}
|
|
248
69
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Copies the matrix contents into a 6 entry float array. If target is null
|
|
72
|
+
* (or not the correct size), a new array will be created. Returned in the
|
|
73
|
+
* order {@code {m00, m01, m02, m10, m11, m12}}.
|
|
74
|
+
*/
|
|
75
|
+
public float[] get(float[] target) {
|
|
76
|
+
if ((target == null) || (target.length != 6)) {
|
|
77
|
+
target = new float[6];
|
|
78
|
+
}
|
|
79
|
+
target[0] = m00;
|
|
80
|
+
target[1] = m01;
|
|
81
|
+
target[2] = m02;
|
|
82
|
+
|
|
83
|
+
target[3] = m10;
|
|
84
|
+
target[4] = m11;
|
|
85
|
+
target[5] = m12;
|
|
86
|
+
|
|
87
|
+
return target;
|
|
254
88
|
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
public void apply(PMatrix2D source) {
|
|
259
|
-
apply(source.m00, source.m01, source.m02,
|
|
260
|
-
source.m10, source.m11, source.m12);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Unavailable in 2D.
|
|
266
|
-
* @throws IllegalArgumentException
|
|
267
|
-
*/
|
|
268
|
-
public void apply(PMatrix3D source) {
|
|
269
|
-
throw new IllegalArgumentException("Cannot use apply(PMatrix3D) on a PMatrix2D.");
|
|
270
|
-
}
|
|
271
89
|
|
|
90
|
+
/**
|
|
91
|
+
* If matrix is a PMatrix2D, sets this matrix to be a copy of it.
|
|
92
|
+
*
|
|
93
|
+
* @throws IllegalArgumentException If <tt>matrix</tt> is not 2D.
|
|
94
|
+
*/
|
|
95
|
+
public void set(PMatrix matrix) {
|
|
96
|
+
if (matrix instanceof PMatrix2D) {
|
|
97
|
+
PMatrix2D src = (PMatrix2D) matrix;
|
|
98
|
+
set(src.m00, src.m01, src.m02,
|
|
99
|
+
src.m10, src.m11, src.m12);
|
|
100
|
+
} else {
|
|
101
|
+
throw new IllegalArgumentException("PMatrix2D.set() only accepts PMatrix2D objects.");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
272
104
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
m01 = n01 * t0 + n11 * t1;
|
|
279
|
-
m02 += n02 * t0 + n12 * t1;
|
|
105
|
+
/**
|
|
106
|
+
* Unavailable in 2D. Does nothing.
|
|
107
|
+
*/
|
|
108
|
+
public void set(PMatrix3D src) {
|
|
109
|
+
}
|
|
280
110
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
m12 += n02 * t0 + n12 * t1;
|
|
286
|
-
}
|
|
111
|
+
public void set(float[] source) {
|
|
112
|
+
m00 = source[0];
|
|
113
|
+
m01 = source[1];
|
|
114
|
+
m02 = source[2];
|
|
287
115
|
|
|
116
|
+
m10 = source[3];
|
|
117
|
+
m11 = source[4];
|
|
118
|
+
m12 = source[5];
|
|
119
|
+
}
|
|
288
120
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Sets the matrix content.
|
|
123
|
+
*/
|
|
124
|
+
public void set(float m00, float m01, float m02,
|
|
125
|
+
float m10, float m11, float m12) {
|
|
126
|
+
this.m00 = m00;
|
|
127
|
+
this.m01 = m01;
|
|
128
|
+
this.m02 = m02;
|
|
129
|
+
this.m10 = m10;
|
|
130
|
+
this.m11 = m11;
|
|
131
|
+
this.m12 = m12;
|
|
132
|
+
}
|
|
299
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Unavailable in 2D. Does nothing.
|
|
136
|
+
*/
|
|
137
|
+
public void set(float m00, float m01, float m02, float m03,
|
|
138
|
+
float m10, float m11, float m12, float m13,
|
|
139
|
+
float m20, float m21, float m22, float m23,
|
|
140
|
+
float m30, float m31, float m32, float m33) {
|
|
300
141
|
|
|
301
|
-
/**
|
|
302
|
-
* Apply another matrix to the left of this one.
|
|
303
|
-
*/
|
|
304
|
-
public void preApply(PMatrix source) {
|
|
305
|
-
if (source instanceof PMatrix2D) {
|
|
306
|
-
preApply((PMatrix2D) source);
|
|
307
|
-
} else if (source instanceof PMatrix3D) {
|
|
308
|
-
preApply((PMatrix3D) source);
|
|
309
142
|
}
|
|
310
|
-
}
|
|
311
143
|
|
|
144
|
+
public void translate(float tx, float ty) {
|
|
145
|
+
m02 = tx * m00 + ty * m01 + m02;
|
|
146
|
+
m12 = tx * m10 + ty * m11 + m12;
|
|
147
|
+
}
|
|
312
148
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Unavailable in 2D.
|
|
151
|
+
*
|
|
152
|
+
* @throws IllegalArgumentException
|
|
153
|
+
*/
|
|
154
|
+
public void translate(float x, float y, float z) {
|
|
155
|
+
throw new IllegalArgumentException("Cannot use translate(x, y, z) on a PMatrix2D.");
|
|
156
|
+
}
|
|
317
157
|
|
|
158
|
+
// Implementation roughly based on AffineTransform.
|
|
159
|
+
public void rotate(float angle) {
|
|
160
|
+
float s = sin(angle);
|
|
161
|
+
float c = cos(angle);
|
|
162
|
+
|
|
163
|
+
float temp1 = m00;
|
|
164
|
+
float temp2 = m01;
|
|
165
|
+
m00 = c * temp1 + s * temp2;
|
|
166
|
+
m01 = -s * temp1 + c * temp2;
|
|
167
|
+
temp1 = m10;
|
|
168
|
+
temp2 = m11;
|
|
169
|
+
m10 = c * temp1 + s * temp2;
|
|
170
|
+
m11 = -s * temp1 + c * temp2;
|
|
171
|
+
}
|
|
318
172
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Unavailable in 2D.
|
|
175
|
+
*
|
|
176
|
+
* @throws IllegalArgumentException
|
|
177
|
+
*/
|
|
178
|
+
public void rotateX(float angle) {
|
|
179
|
+
throw new IllegalArgumentException("Cannot use rotateX() on a PMatrix2D.");
|
|
180
|
+
}
|
|
326
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Unavailable in 2D.
|
|
184
|
+
*
|
|
185
|
+
* @throws IllegalArgumentException
|
|
186
|
+
*/
|
|
187
|
+
public void rotateY(float angle) {
|
|
188
|
+
throw new IllegalArgumentException("Cannot use rotateY() on a PMatrix2D.");
|
|
189
|
+
}
|
|
327
190
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
float t1 = m12;
|
|
332
|
-
n02 += t0 * n00 + t1 * n01;
|
|
333
|
-
n12 += t0 * n10 + t1 * n11;
|
|
191
|
+
public void rotateZ(float angle) {
|
|
192
|
+
rotate(angle);
|
|
193
|
+
}
|
|
334
194
|
|
|
335
|
-
|
|
336
|
-
|
|
195
|
+
/**
|
|
196
|
+
* Unavailable in 2D.
|
|
197
|
+
*
|
|
198
|
+
* @throws IllegalArgumentException
|
|
199
|
+
*/
|
|
200
|
+
public void rotate(float angle, float v0, float v1, float v2) {
|
|
201
|
+
throw new IllegalArgumentException("Cannot use this version of rotate() on a PMatrix2D.");
|
|
202
|
+
}
|
|
337
203
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
m10 = t0 * n10 + t1 * n11;
|
|
204
|
+
public void scale(float s) {
|
|
205
|
+
scale(s, s);
|
|
206
|
+
}
|
|
342
207
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
208
|
+
public void scale(float sx, float sy) {
|
|
209
|
+
m00 *= sx;
|
|
210
|
+
m01 *= sy;
|
|
211
|
+
m10 *= sx;
|
|
212
|
+
m11 *= sy;
|
|
213
|
+
}
|
|
348
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Unavailable in 2D.
|
|
217
|
+
*
|
|
218
|
+
* @throws IllegalArgumentException
|
|
219
|
+
*/
|
|
220
|
+
public void scale(float x, float y, float z) {
|
|
221
|
+
throw new IllegalArgumentException("Cannot use this version of scale() on a PMatrix2D.");
|
|
222
|
+
}
|
|
349
223
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
*/
|
|
354
|
-
public void preApply(float n00, float n01, float n02, float n03,
|
|
355
|
-
float n10, float n11, float n12, float n13,
|
|
356
|
-
float n20, float n21, float n22, float n23,
|
|
357
|
-
float n30, float n31, float n32, float n33) {
|
|
358
|
-
throw new IllegalArgumentException("Cannot use this version of preApply() on a PMatrix2D.");
|
|
359
|
-
}
|
|
224
|
+
public void shearX(float angle) {
|
|
225
|
+
apply(1, 0, 1, tan(angle), 0, 0);
|
|
226
|
+
}
|
|
360
227
|
|
|
228
|
+
public void shearY(float angle) {
|
|
229
|
+
apply(1, 0, 1, 0, tan(angle), 0);
|
|
230
|
+
}
|
|
361
231
|
|
|
362
|
-
|
|
232
|
+
public void apply(PMatrix source) {
|
|
233
|
+
if (source instanceof PMatrix2D) {
|
|
234
|
+
apply((PMatrix2D) source);
|
|
235
|
+
} else if (source instanceof PMatrix3D) {
|
|
236
|
+
apply((PMatrix3D) source);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
363
239
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
* Ignores any z component.
|
|
368
|
-
*/
|
|
369
|
-
public PVector mult(PVector source, PVector target) {
|
|
370
|
-
if (target == null) {
|
|
371
|
-
target = new PVector();
|
|
240
|
+
public void apply(PMatrix2D source) {
|
|
241
|
+
apply(source.m00, source.m01, source.m02,
|
|
242
|
+
source.m10, source.m11, source.m12);
|
|
372
243
|
}
|
|
373
|
-
target.x = m00*source.x + m01*source.y + m02;
|
|
374
|
-
target.y = m10*source.x + m11*source.y + m12;
|
|
375
|
-
return target;
|
|
376
|
-
}
|
|
377
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Unavailable in 2D.
|
|
247
|
+
*
|
|
248
|
+
* @throws IllegalArgumentException
|
|
249
|
+
*/
|
|
250
|
+
public void apply(PMatrix3D source) {
|
|
251
|
+
throw new IllegalArgumentException("Cannot use apply(PMatrix3D) on a PMatrix2D.");
|
|
252
|
+
}
|
|
378
253
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
254
|
+
public void apply(float n00, float n01, float n02,
|
|
255
|
+
float n10, float n11, float n12) {
|
|
256
|
+
float t0 = m00;
|
|
257
|
+
float t1 = m01;
|
|
258
|
+
m00 = n00 * t0 + n10 * t1;
|
|
259
|
+
m01 = n01 * t0 + n11 * t1;
|
|
260
|
+
m02 += n02 * t0 + n12 * t1;
|
|
261
|
+
|
|
262
|
+
t0 = m10;
|
|
263
|
+
t1 = m11;
|
|
264
|
+
m10 = n00 * t0 + n10 * t1;
|
|
265
|
+
m11 = n01 * t0 + n11 * t1;
|
|
266
|
+
m12 += n02 * t0 + n12 * t1;
|
|
387
267
|
}
|
|
388
268
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
269
|
+
/**
|
|
270
|
+
* Unavailable in 2D.
|
|
271
|
+
*
|
|
272
|
+
* @throws IllegalArgumentException
|
|
273
|
+
*/
|
|
274
|
+
public void apply(float n00, float n01, float n02, float n03,
|
|
275
|
+
float n10, float n11, float n12, float n13,
|
|
276
|
+
float n20, float n21, float n22, float n23,
|
|
277
|
+
float n30, float n31, float n32, float n33) {
|
|
278
|
+
throw new IllegalArgumentException("Cannot use this version of apply() on a PMatrix2D.");
|
|
279
|
+
}
|
|
392
280
|
|
|
393
|
-
|
|
394
|
-
|
|
281
|
+
/**
|
|
282
|
+
* Apply another matrix to the left of this one.
|
|
283
|
+
*/
|
|
284
|
+
public void preApply(PMatrix source) {
|
|
285
|
+
if (source instanceof PMatrix2D) {
|
|
286
|
+
preApply((PMatrix2D) source);
|
|
287
|
+
} else if (source instanceof PMatrix3D) {
|
|
288
|
+
preApply((PMatrix3D) source);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
395
291
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
292
|
+
public void preApply(PMatrix2D left) {
|
|
293
|
+
preApply(left.m00, left.m01, left.m02,
|
|
294
|
+
left.m10, left.m11, left.m12);
|
|
399
295
|
}
|
|
400
296
|
|
|
401
|
-
|
|
402
|
-
|
|
297
|
+
/**
|
|
298
|
+
* Unavailable in 2D.
|
|
299
|
+
*
|
|
300
|
+
* @throws IllegalArgumentException
|
|
301
|
+
*/
|
|
302
|
+
public void preApply(PMatrix3D left) {
|
|
303
|
+
throw new IllegalArgumentException("Cannot use preApply(PMatrix3D) on a PMatrix2D.");
|
|
304
|
+
}
|
|
403
305
|
|
|
306
|
+
public void preApply(float n00, float n01, float n02,
|
|
307
|
+
float n10, float n11, float n12) {
|
|
308
|
+
float t0 = m02;
|
|
309
|
+
float t1 = m12;
|
|
310
|
+
n02 += t0 * n00 + t1 * n01;
|
|
311
|
+
n12 += t0 * n10 + t1 * n11;
|
|
312
|
+
|
|
313
|
+
m02 = n02;
|
|
314
|
+
m12 = n12;
|
|
315
|
+
|
|
316
|
+
t0 = m00;
|
|
317
|
+
t1 = m10;
|
|
318
|
+
m00 = t0 * n00 + t1 * n01;
|
|
319
|
+
m10 = t0 * n10 + t1 * n11;
|
|
320
|
+
|
|
321
|
+
t0 = m01;
|
|
322
|
+
t1 = m11;
|
|
323
|
+
m01 = t0 * n00 + t1 * n01;
|
|
324
|
+
m11 = t0 * n10 + t1 * n11;
|
|
325
|
+
}
|
|
404
326
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
327
|
+
/**
|
|
328
|
+
* Unavailable in 2D.
|
|
329
|
+
*
|
|
330
|
+
* @throws IllegalArgumentException
|
|
331
|
+
*/
|
|
332
|
+
public void preApply(float n00, float n01, float n02, float n03,
|
|
333
|
+
float n10, float n11, float n12, float n13,
|
|
334
|
+
float n20, float n21, float n22, float n23,
|
|
335
|
+
float n30, float n31, float n32, float n33) {
|
|
336
|
+
throw new IllegalArgumentException("Cannot use this version of preApply() on a PMatrix2D.");
|
|
337
|
+
}
|
|
412
338
|
|
|
339
|
+
//////////////////////////////////////////////////////////////
|
|
340
|
+
/**
|
|
341
|
+
* {@inheritDoc} Ignores any z component.
|
|
342
|
+
*/
|
|
343
|
+
public PVector mult(PVector source, PVector target) {
|
|
344
|
+
if (target == null) {
|
|
345
|
+
target = new PVector();
|
|
346
|
+
}
|
|
347
|
+
target.x = m00 * source.x + m01 * source.y + m02;
|
|
348
|
+
target.y = m10 * source.x + m11 * source.y + m12;
|
|
349
|
+
return target;
|
|
350
|
+
}
|
|
413
351
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Multiply a two element vector against this matrix. If out is null or not
|
|
354
|
+
* length four, a new float array will be returned. The values for vec and
|
|
355
|
+
* out can be the same (though that's less efficient).
|
|
356
|
+
*/
|
|
357
|
+
public float[] mult(float vec[], float out[]) {
|
|
358
|
+
if (out == null || out.length != 2) {
|
|
359
|
+
out = new float[2];
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (vec == out) {
|
|
363
|
+
float tx = m00 * vec[0] + m01 * vec[1] + m02;
|
|
364
|
+
float ty = m10 * vec[0] + m11 * vec[1] + m12;
|
|
365
|
+
|
|
366
|
+
out[0] = tx;
|
|
367
|
+
out[1] = ty;
|
|
368
|
+
|
|
369
|
+
} else {
|
|
370
|
+
out[0] = m00 * vec[0] + m01 * vec[1] + m02;
|
|
371
|
+
out[1] = m10 * vec[0] + m11 * vec[1] + m12;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return out;
|
|
375
|
+
}
|
|
421
376
|
|
|
377
|
+
/**
|
|
378
|
+
* Returns the x-coordinate of the result of multiplying the point (x, y) by
|
|
379
|
+
* this matrix.
|
|
380
|
+
*/
|
|
381
|
+
public float multX(float x, float y) {
|
|
382
|
+
return m00 * x + m01 * y + m02;
|
|
383
|
+
}
|
|
422
384
|
|
|
385
|
+
/**
|
|
386
|
+
* Returns the y-coordinate of the result of multiplying the point (x, y) by
|
|
387
|
+
* this matrix.
|
|
388
|
+
*/
|
|
389
|
+
public float multY(float x, float y) {
|
|
390
|
+
return m10 * x + m11 * y + m12;
|
|
391
|
+
}
|
|
423
392
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
393
|
+
/**
|
|
394
|
+
* Unavailable in 2D. Does nothing.
|
|
395
|
+
*/
|
|
396
|
+
public void transpose() {
|
|
397
|
+
}
|
|
429
398
|
|
|
430
399
|
|
|
431
|
-
|
|
400
|
+
/*
|
|
432
401
|
* Implementation stolen from OpenJDK.
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
402
|
+
*/
|
|
403
|
+
public boolean invert() {
|
|
404
|
+
float determinant = determinant();
|
|
405
|
+
if (Math.abs(determinant) <= Float.MIN_VALUE) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
float t00 = m00;
|
|
410
|
+
float t01 = m01;
|
|
411
|
+
float t02 = m02;
|
|
412
|
+
float t10 = m10;
|
|
413
|
+
float t11 = m11;
|
|
414
|
+
float t12 = m12;
|
|
415
|
+
|
|
416
|
+
m00 = t11 / determinant;
|
|
417
|
+
m10 = -t10 / determinant;
|
|
418
|
+
m01 = -t01 / determinant;
|
|
419
|
+
m11 = t00 / determinant;
|
|
420
|
+
m02 = (t01 * t12 - t11 * t02) / determinant;
|
|
421
|
+
m12 = (t10 * t02 - t00 * t12) / determinant;
|
|
422
|
+
|
|
423
|
+
return true;
|
|
438
424
|
}
|
|
439
425
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
float
|
|
444
|
-
|
|
445
|
-
float t12 = m12;
|
|
446
|
-
|
|
447
|
-
m00 = t11 / determinant;
|
|
448
|
-
m10 = -t10 / determinant;
|
|
449
|
-
m01 = -t01 / determinant;
|
|
450
|
-
m11 = t00 / determinant;
|
|
451
|
-
m02 = (t01 * t12 - t11 * t02) / determinant;
|
|
452
|
-
m12 = (t10 * t02 - t00 * t12) / determinant;
|
|
453
|
-
|
|
454
|
-
return true;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* @return the determinant of the matrix
|
|
460
|
-
*/
|
|
461
|
-
public float determinant() {
|
|
462
|
-
return m00 * m11 - m01 * m10;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
//////////////////////////////////////////////////////////////
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
public void print() {
|
|
470
|
-
int big = (int) abs(max(PApplet.max(abs(m00), abs(m01), abs(m02)),
|
|
471
|
-
PApplet.max(abs(m10), abs(m11), abs(m12))));
|
|
472
|
-
|
|
473
|
-
int digits = 1;
|
|
474
|
-
if (Float.isNaN(big) || Float.isInfinite(big)) { // avoid infinite loop
|
|
475
|
-
digits = 5;
|
|
476
|
-
} else {
|
|
477
|
-
while ((big /= 10) != 0) digits++; // cheap log()
|
|
426
|
+
/**
|
|
427
|
+
* @return the determinant of the matrix
|
|
428
|
+
*/
|
|
429
|
+
public float determinant() {
|
|
430
|
+
return m00 * m11 - m01 * m10;
|
|
478
431
|
}
|
|
479
432
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
// TODO make this more efficient, or move into PMatrix2D
|
|
506
|
-
protected boolean isWarped() {
|
|
507
|
-
return ((m00 != 1) || (m01 != 0) &&
|
|
508
|
-
(m10 != 0) || (m11 != 1));
|
|
509
|
-
}
|
|
510
|
-
|
|
433
|
+
//////////////////////////////////////////////////////////////
|
|
434
|
+
public void print() {
|
|
435
|
+
int big = (int) abs(max(PApplet.max(abs(m00), abs(m01), abs(m02)),
|
|
436
|
+
PApplet.max(abs(m10), abs(m11), abs(m12))));
|
|
437
|
+
|
|
438
|
+
int digits = 1;
|
|
439
|
+
if (Float.isNaN(big) || Float.isInfinite(big)) { // avoid infinite loop
|
|
440
|
+
digits = 5;
|
|
441
|
+
} else {
|
|
442
|
+
while ((big /= 10) != 0) {
|
|
443
|
+
digits++; // cheap log()
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
System.out.println(PApplet.nfs(m00, digits, 4) + " "
|
|
448
|
+
+ PApplet.nfs(m01, digits, 4) + " "
|
|
449
|
+
+ PApplet.nfs(m02, digits, 4));
|
|
450
|
+
|
|
451
|
+
System.out.println(PApplet.nfs(m10, digits, 4) + " "
|
|
452
|
+
+ PApplet.nfs(m11, digits, 4) + " "
|
|
453
|
+
+ PApplet.nfs(m12, digits, 4));
|
|
454
|
+
|
|
455
|
+
System.out.println();
|
|
456
|
+
}
|
|
511
457
|
|
|
512
|
-
|
|
458
|
+
//////////////////////////////////////////////////////////////
|
|
459
|
+
// TODO these need to be added as regular API, but the naming and
|
|
460
|
+
// implementation needs to be improved first. (e.g. actually keeping track
|
|
461
|
+
// of whether the matrix is in fact identity internally.)
|
|
462
|
+
protected boolean isIdentity() {
|
|
463
|
+
return ((m00 == 1) && (m01 == 0) && (m02 == 0)
|
|
464
|
+
&& (m10 == 0) && (m11 == 1) && (m12 == 0));
|
|
465
|
+
}
|
|
513
466
|
|
|
467
|
+
// TODO make this more efficient, or move into PMatrix2D
|
|
468
|
+
protected boolean isWarped() {
|
|
469
|
+
return ((m00 != 1) || (m01 != 0)
|
|
470
|
+
&& (m10 != 0) || (m11 != 1));
|
|
471
|
+
}
|
|
514
472
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
473
|
+
//////////////////////////////////////////////////////////////
|
|
474
|
+
static private final float max(float a, float b) {
|
|
475
|
+
return (a > b) ? a : b;
|
|
476
|
+
}
|
|
518
477
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
478
|
+
static private final float abs(float a) {
|
|
479
|
+
return (a < 0) ? -a : a;
|
|
480
|
+
}
|
|
522
481
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
482
|
+
static private final float sin(float angle) {
|
|
483
|
+
return (float) Math.sin(angle);
|
|
484
|
+
}
|
|
526
485
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
486
|
+
static private final float cos(float angle) {
|
|
487
|
+
return (float) Math.cos(angle);
|
|
488
|
+
}
|
|
530
489
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
490
|
+
static private final float tan(float angle) {
|
|
491
|
+
return (float) Math.tan(angle);
|
|
492
|
+
}
|
|
534
493
|
}
|