FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing4/core/src/processing/core/PMatrix.java at main · processing/processing4 · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
processing
/
processing4
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
177
Star
474
Code
Issues
256
Pull requests
26
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
processing4
/
core
/
src
/
processing
/
core
/
PMatrix.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
212 lines (160 loc) · 5.95 KB
Breadcrumbs
processing4
/
core
/
src
/
processing
/
core
/
PMatrix.java
Copy path
File metadata and controls
212 lines (160 loc) · 5.95 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2005-08 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/
package
processing
.
core
;
/**
* A matrix is used to define graphical transformations. PMatrix is the common
* interface for both the 2D and 3D matrix classes in Processing. A matrix is a
* grid of numbers, which can be multiplied by a vector to give another vector.
* Multiplying a point by a particular matrix might translate it, rotate it,
* or carry out a combination of transformations.
*
* Multiplying matrices by each other combines their effects; use the
* {@code apply} and {@code preApply} methods for this.
*/
public
interface
PMatrix
{
/**
* Make this an identity matrix. Multiplying by it will have no effect.
*/
public
void
reset
();
/**
* Returns a copy of this PMatrix.
*/
public
PMatrix
get
();
/**
* Copies the matrix contents into a float array.
* If target is null (or not the correct size), a new array will be created.
*/
public
float
[]
get
(
float
[]
target
);
/**
* Make this matrix become a copy of src.
*/
public
void
set
(
PMatrix
src
);
/**
* Set the contents of this matrix to the contents of source. Fills the
* matrix left-to-right, starting in the top row.
*/
public
void
set
(
float
[]
source
);
/**
* Set the matrix content to this 2D matrix or its 3D equivalent.
*/
public
void
set
(
float
m00
,
float
m01
,
float
m02
,
float
m10
,
float
m11
,
float
m12
);
/**
* Set the matrix content to the 3D matrix supplied, if this matrix is 3D.
*/
public
void
set
(
float
m00
,
float
m01
,
float
m02
,
float
m03
,
float
m10
,
float
m11
,
float
m12
,
float
m13
,
float
m20
,
float
m21
,
float
m22
,
float
m23
,
float
m30
,
float
m31
,
float
m32
,
float
m33
);
public
void
translate
(
float
tx
,
float
ty
);
public
void
translate
(
float
tx
,
float
ty
,
float
tz
);
public
void
rotate
(
float
angle
);
public
void
rotateX
(
float
angle
);
public
void
rotateY
(
float
angle
);
public
void
rotateZ
(
float
angle
);
public
void
rotate
(
float
angle
,
float
v0
,
float
v1
,
float
v2
);
public
void
scale
(
float
s
);
public
void
scale
(
float
sx
,
float
sy
);
public
void
scale
(
float
x
,
float
y
,
float
z
);
public
void
shearX
(
float
angle
);
public
void
shearY
(
float
angle
);
/**
* Multiply this matrix by another.
*/
public
void
apply
(
PMatrix
source
);
/**
* Multiply this matrix by another.
*/
public
void
apply
(
PMatrix2D
source
);
/**
* Multiply this matrix by another.
*/
public
void
apply
(
PMatrix3D
source
);
/**
* Multiply this matrix by another.
*/
public
void
apply
(
float
n00
,
float
n01
,
float
n02
,
float
n10
,
float
n11
,
float
n12
);
/**
* Multiply this matrix by another.
*/
public
void
apply
(
float
n00
,
float
n01
,
float
n02
,
float
n03
,
float
n10
,
float
n11
,
float
n12
,
float
n13
,
float
n20
,
float
n21
,
float
n22
,
float
n23
,
float
n30
,
float
n31
,
float
n32
,
float
n33
);
/**
* Apply another matrix to the left of this one.
*/
public
void
preApply
(
PMatrix
left
);
/**
* Apply another matrix to the left of this one.
*/
public
void
preApply
(
PMatrix2D
left
);
/**
* Apply another matrix to the left of this one. 3D only.
*/
public
void
preApply
(
PMatrix3D
left
);
/**
* Apply another matrix to the left of this one.
*/
public
void
preApply
(
float
n00
,
float
n01
,
float
n02
,
float
n10
,
float
n11
,
float
n12
);
/**
* Apply another matrix to the left of this one. 3D only.
*/
public
void
preApply
(
float
n00
,
float
n01
,
float
n02
,
float
n03
,
float
n10
,
float
n11
,
float
n12
,
float
n13
,
float
n20
,
float
n21
,
float
n22
,
float
n23
,
float
n30
,
float
n31
,
float
n32
,
float
n33
);
/**
* Multiply source by this matrix, and return the result.
* The result will be stored in target if target is non-null, and target
* will then be the matrix returned. This improves performance if you reuse
* target, so it's recommended if you call this many times in draw().
*/
public
PVector
mult
(
PVector
source
,
PVector
target
);
/**
* Multiply a multi-element vector against this matrix.
* Supplying and recycling a target array improves performance, so it's
* recommended if you call this many times in draw().
*/
public
float
[]
mult
(
float
[]
source
,
float
[]
target
);
// public float multX(float x, float y);
// public float multY(float x, float y);
// public float multX(float x, float y, float z);
// public float multY(float x, float y, float z);
// public float multZ(float x, float y, float z);
/**
* Transpose this matrix; rows become columns and columns rows.
*/
public
void
transpose
();
/**
* Invert this matrix. Will not necessarily succeed, because some matrices
* map more than one point to the same image point, and so are irreversible.
* @return true if successful
*/
public
boolean
invert
();
/**
* @return the determinant of the matrix
*/
public
float
determinant
();
/**
* Print the matrix data to the console.
*/
public
void
print
();
}
Back
|
FazBrowse Home
|
New Git URL