| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7348,7 +7348,7 @@ public void setMatrix(PMatrix source) { | |||
| 7348 | 7348 | } | |
| 7349 | 7349 | ||
| 7350 | 7350 | ||
| 7351 | - public void setMatrix(PMatrix2D source) { | ||
| 7351 | + public void setMatrix(PMatrix2D source) { | ||
| 7352 | 7352 | if (recorder != null) recorder.setMatrix(source); | |
| 7353 | 7353 | g.setMatrix(source); | |
| 7354 | 7354 | } | |
@@ -7424,8 +7424,8 @@ public void perspective(float fovy, float aspect, float zNear, float zFar) { | |||
| 7424 | 7424 | } | |
| 7425 | 7425 | ||
| 7426 | 7426 | ||
| 7427 | - public void frustum(float left, float right, | ||
| 7428 | - float bottom, float top, | ||
| 7427 | + public void frustum(float left, float right, | ||
| 7428 | + float bottom, float top, | ||
| 7429 | 7429 | float near, float far) { | |
| 7430 | 7430 | if (recorder != null) recorder.frustum(left, right, bottom, top, near, far); | |
| 7431 | 7431 | g.frustum(left, right, bottom, top, near, far); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,6 +72,10 @@ public void set(float m00, float m01, float m02, float m03, | |||
| 72 | 72 | public void scale(float sx, float sy); | |
| 73 | 73 | ||
| 74 | 74 | public void scale(float x, float y, float z); | |
| 75 | + | ||
| 76 | + public void skewX(float angle); | ||
| 77 | + | ||
| 78 | + public void skewY(float angle); | ||
| 75 | 79 | ||
| 76 | 80 | /** | |
| 77 | 81 | * Multiply this matrix by another. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,20 +38,20 @@ public PMatrix2D() { | |||
| 38 | 38 | } | |
| 39 | 39 | ||
| 40 | 40 | ||
| 41 | - public PMatrix2D(float m00, float m01, float m02, | ||
| 41 | + public PMatrix2D(float m00, float m01, float m02, | ||
| 42 | 42 | float m10, float m11, float m12) { | |
| 43 | 43 | set(m00, m01, m02, | |
| 44 | 44 | m10, m11, m12); | |
| 45 | 45 | } | |
| 46 | - | ||
| 47 | - | ||
| 46 | + | ||
| 47 | + | ||
| 48 | 48 | public PMatrix2D(PMatrix matrix) { | |
| 49 | 49 | set(matrix); | |
| 50 | 50 | } | |
| 51 | - | ||
| 51 | + | ||
| 52 | 52 | ||
| 53 | 53 | public void reset() { | |
| 54 | - set(1, 0, 0, | ||
| 54 | + set(1, 0, 0, | ||
| 55 | 55 | 0, 1, 0); | |
| 56 | 56 | } | |
| 57 | 57 | ||
@@ -64,8 +64,8 @@ public PMatrix2D get() { | |||
| 64 | 64 | outgoing.set(this); | |
| 65 | 65 | return outgoing; | |
| 66 | 66 | } | |
| 67 | - | ||
| 68 | - | ||
| 67 | + | ||
| 68 | + | ||
| 69 | 69 | /** | |
| 70 | 70 | * Copies the matrix contents into a 6 entry float array. | |
| 71 | 71 | * If target is null (or not the correct size), a new array will be created. | |
@@ -77,14 +77,14 @@ public float[] get(float[] target) { | |||
| 77 | 77 | target[0] = m00; | |
| 78 | 78 | target[1] = m01; | |
| 79 | 79 | target[2] = m02; | |
| 80 | - | ||
| 80 | + | ||
| 81 | 81 | target[3] = m10; | |
| 82 | 82 | target[4] = m11; | |
| 83 | 83 | target[5] = m12; | |
| 84 | 84 | ||
| 85 | 85 | return target; | |
| 86 | 86 | } | |
| 87 | - | ||
| 87 | + | ||
| 88 | 88 | ||
| 89 | 89 | public void set(PMatrix matrix) { | |
| 90 | 90 | if (matrix instanceof PMatrix2D) { | |
@@ -95,8 +95,8 @@ public void set(PMatrix matrix) { | |||
| 95 | 95 | throw new IllegalArgumentException("PMatrix2D.set() only accepts PMatrix2D objects."); | |
| 96 | 96 | } | |
| 97 | 97 | } | |
| 98 | - | ||
| 99 | - | ||
| 98 | + | ||
| 99 | + | ||
| 100 | 100 | public void set(PMatrix3D src) { | |
| 101 | 101 | } | |
| 102 | 102 | ||
@@ -110,34 +110,34 @@ public void set(float[] source) { | |||
| 110 | 110 | m11 = source[4]; | |
| 111 | 111 | m12 = source[5]; | |
| 112 | 112 | } | |
| 113 | - | ||
| 114 | - | ||
| 115 | - public void set(float m00, float m01, float m02, | ||
| 113 | + | ||
| 114 | + | ||
| 115 | + public void set(float m00, float m01, float m02, | ||
| 116 | 116 | float m10, float m11, float m12) { | |
| 117 | - this.m00 = m00; this.m01 = m01; this.m02 = m02; | ||
| 117 | + this.m00 = m00; this.m01 = m01; this.m02 = m02; | ||
| 118 | 118 | this.m10 = m10; this.m11 = m11; this.m12 = m12; | |
| 119 | 119 | } | |
| 120 | - | ||
| 121 | - | ||
| 120 | + | ||
| 121 | + | ||
| 122 | 122 | public void set(float m00, float m01, float m02, float m03, | |
| 123 | 123 | float m10, float m11, float m12, float m13, | |
| 124 | 124 | float m20, float m21, float m22, float m23, | |
| 125 | 125 | float m30, float m31, float m32, float m33) { | |
| 126 | - | ||
| 126 | + | ||
| 127 | 127 | } | |
| 128 | 128 | ||
| 129 | 129 | ||
| 130 | - public void translate(float tx, float ty) { | ||
| 130 | + public void translate(float tx, float ty) { | ||
| 131 | 131 | m02 = tx*m00 + ty*m01 + m02; | |
| 132 | 132 | m12 = tx*m10 + ty*m11 + m12; | |
| 133 | 133 | } | |
| 134 | - | ||
| 135 | - | ||
| 134 | + | ||
| 135 | + | ||
| 136 | 136 | public void translate(float x, float y, float z) { | |
| 137 | 137 | throw new IllegalArgumentException("Cannot use translate(x, y, z) on a PMatrix2D."); | |
| 138 | 138 | } | |
| 139 | 139 | ||
| 140 | - | ||
| 140 | + | ||
| 141 | 141 | // Implementation roughly based on AffineTransform. | |
| 142 | 142 | public void rotate(float angle) { | |
| 143 | 143 | float s = sin(angle); | |
@@ -180,8 +180,8 @@ public void scale(float s) { | |||
| 180 | 180 | ||
| 181 | 181 | ||
| 182 | 182 | public void scale(float sx, float sy) { | |
| 183 | - m00 *= sx; m01 *= sy; | ||
| 184 | - m10 *= sx; m11 *= sy; | ||
| 183 | + m00 *= sx; m01 *= sy; | ||
| 184 | + m10 *= sx; m11 *= sy; | ||
| 185 | 185 | } | |
| 186 | 186 | ||
| 187 | 187 | ||
@@ -190,27 +190,37 @@ public void scale(float x, float y, float z) { | |||
| 190 | 190 | } | |
| 191 | 191 | ||
| 192 | 192 | ||
| 193 | + public void skewX(float angle) { | ||
| 194 | + apply(1, 0, 1, angle, 0, 0); | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + | ||
| 198 | + public void skewY(float angle) { | ||
| 199 | + apply(1, 0, 1, 0, angle, 0); | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + | ||
| 193 | 203 | public void apply(PMatrix source) { | |
| 194 | 204 | if (source instanceof PMatrix2D) { | |
| 195 | 205 | apply((PMatrix2D) source); | |
| 196 | 206 | } else if (source instanceof PMatrix3D) { | |
| 197 | 207 | apply((PMatrix3D) source); | |
| 198 | 208 | } | |
| 199 | 209 | } | |
| 200 | - | ||
| 210 | + | ||
| 201 | 211 | ||
| 202 | 212 | public void apply(PMatrix2D source) { | |
| 203 | - apply(source.m00, source.m01, source.m02, | ||
| 213 | + apply(source.m00, source.m01, source.m02, | ||
| 204 | 214 | source.m10, source.m11, source.m12); | |
| 205 | 215 | } | |
| 206 | - | ||
| 207 | - | ||
| 216 | + | ||
| 217 | + | ||
| 208 | 218 | public void apply(PMatrix3D source) { | |
| 209 | 219 | throw new IllegalArgumentException("Cannot use apply(PMatrix3D) on a PMatrix2D."); | |
| 210 | 220 | } | |
| 211 | - | ||
| 212 | - | ||
| 213 | - public void apply(float n00, float n01, float n02, | ||
| 221 | + | ||
| 222 | + | ||
| 223 | + public void apply(float n00, float n01, float n02, | ||
| 214 | 224 | float n10, float n11, float n12) { | |
| 215 | 225 | float t0 = m00; | |
| 216 | 226 | float t1 = m01; | |
@@ -222,7 +232,7 @@ public void apply(float n00, float n01, float n02, | |||
| 222 | 232 | t1 = m11; | |
| 223 | 233 | m10 = n00 * t0 + n10 * t1; | |
| 224 | 234 | m11 = n01 * t0 + n11 * t1; | |
| 225 | - m12 += n02 * t0 + n12 * t1; | ||
| 235 | + m12 += n02 * t0 + n12 * t1; | ||
| 226 | 236 | } | |
| 227 | 237 | ||
| 228 | 238 | ||
@@ -241,8 +251,8 @@ public void preApply(PMatrix2D left) { | |||
| 241 | 251 | preApply(left.m00, left.m01, left.m02, | |
| 242 | 252 | left.m10, left.m11, left.m12); | |
| 243 | 253 | } | |
| 244 | - | ||
| 245 | - | ||
| 254 | + | ||
| 255 | + | ||
| 246 | 256 | public void preApply(PMatrix3D left) { | |
| 247 | 257 | throw new IllegalArgumentException("Cannot use preApply(PMatrix3D) on a PMatrix2D."); | |
| 248 | 258 | } | |
@@ -266,7 +276,7 @@ public void preApply(float n00, float n01, float n02, | |||
| 266 | 276 | t0 = m01; | |
| 267 | 277 | t1 = m11; | |
| 268 | 278 | m01 = t0 * n00 + t1 * n01; | |
| 269 | - m11 = t0 * n10 + t1 * n11; | ||
| 279 | + m11 = t0 * n10 + t1 * n11; | ||
| 270 | 280 | } | |
| 271 | 281 | ||
| 272 | 282 | ||
@@ -293,17 +303,17 @@ public PVector mult(PVector source, PVector target) { | |||
| 293 | 303 | return target; | |
| 294 | 304 | } | |
| 295 | 305 | ||
| 296 | - | ||
| 297 | - /** | ||
| 298 | - * Multiply a two element vector against this matrix. | ||
| 306 | + | ||
| 307 | + /** | ||
| 308 | + * Multiply a two element vector against this matrix. | ||
| 299 | 309 | * If out is null or not length four, a new float array will be returned. | |
| 300 | - * The values for vec and out can be the same (though that's less efficient). | ||
| 310 | + * The values for vec and out can be the same (though that's less efficient). | ||
| 301 | 311 | */ | |
| 302 | 312 | public float[] mult(float vec[], float out[]) { | |
| 303 | 313 | if (out == null || out.length != 2) { | |
| 304 | 314 | out = new float[2]; | |
| 305 | 315 | } | |
| 306 | - | ||
| 316 | + | ||
| 307 | 317 | if (vec == out) { | |
| 308 | 318 | float tx = m00*vec[0] + m01*vec[1] + m02; | |
| 309 | 319 | float ty = m10*vec[0] + m11*vec[1] + m12; | |
@@ -315,21 +325,21 @@ public float[] mult(float vec[], float out[]) { | |||
| 315 | 325 | out[0] = m00*vec[0] + m01*vec[1] + m02; | |
| 316 | 326 | out[1] = m10*vec[0] + m11*vec[1] + m12; | |
| 317 | 327 | } | |
| 318 | - | ||
| 328 | + | ||
| 319 | 329 | return out; | |
| 320 | 330 | } | |
| 321 | - | ||
| 322 | - | ||
| 331 | + | ||
| 332 | + | ||
| 323 | 333 | public float multX(float x, float y) { | |
| 324 | 334 | return m00*x + m01*y + m02; | |
| 325 | 335 | } | |
| 326 | - | ||
| 327 | - | ||
| 336 | + | ||
| 337 | + | ||
| 328 | 338 | public float multY(float x, float y) { | |
| 329 | 339 | return m10*x + m11*y + m12; | |
| 330 | 340 | } | |
| 331 | - | ||
| 332 | - | ||
| 341 | + | ||
| 342 | + | ||
| 333 | 343 | /** | |
| 334 | 344 | * Transpose this matrix. | |
| 335 | 345 | */ | |
@@ -346,33 +356,33 @@ public boolean invert() { | |||
| 346 | 356 | if (Math.abs(determinant) <= Float.MIN_VALUE) { | |
| 347 | 357 | return false; | |
| 348 | 358 | } | |
| 349 | - | ||
| 350 | - float t00 = m00; | ||
| 351 | - float t01 = m01; | ||
| 359 | + | ||
| 360 | + float t00 = m00; | ||
| 361 | + float t01 = m01; | ||
| 352 | 362 | float t02 = m02; | |
| 353 | - float t10 = m10; | ||
| 354 | - float t11 = m11; | ||
| 363 | + float t10 = m10; | ||
| 364 | + float t11 = m11; | ||
| 355 | 365 | float t12 = m12; | |
| 356 | 366 | ||
| 357 | 367 | m00 = t11 / determinant; | |
| 358 | 368 | m10 = -t10 / determinant; | |
| 359 | 369 | m01 = -t01 / determinant; | |
| 360 | 370 | m11 = t00 / determinant; | |
| 361 | 371 | m02 = (t01 * t12 - t11 * t02) / determinant; | |
| 362 | - m12 = (t10 * t02 - t00 * t12) / determinant; | ||
| 363 | - | ||
| 372 | + m12 = (t10 * t02 - t00 * t12) / determinant; | ||
| 373 | + | ||
| 364 | 374 | return true; | |
| 365 | 375 | } | |
| 366 | - | ||
| 367 | - | ||
| 376 | + | ||
| 377 | + | ||
| 368 | 378 | /** | |
| 369 | 379 | * @return the determinant of the matrix | |
| 370 | 380 | */ | |
| 371 | 381 | public float determinant() { | |
| 372 | 382 | return m00 * m11 - m01 * m10; | |
| 373 | 383 | } | |
| 374 | 384 | ||
| 375 | - | ||
| 385 | + | ||
| 376 | 386 | ////////////////////////////////////////////////////////////// | |
| 377 | 387 | ||
| 378 | 388 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments