Skip to content

Commit 356b873

Browse files
committed
Add matrix
1 parent 8580a7f commit 356b873

1 file changed

Lines changed: 36 additions & 8 deletions

File tree

‎CustomView/Advance/[10]Matrix_Method.md‎

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ Matrix matrix = new Matrix();
3838
通过这种方式创建出来的并不是一个数值全部为空的矩阵,而是一个单位矩阵,如下:
3939

4040
![](http://latex.codecogs.com/png.latex?$$
41-
\left [
42-
\begin{matrix}
43-
1 & 0 & 0 \\\
44-
0 & 1 & 0 \\\
41+
\\left [
42+
\\begin{matrix}
43+
1 & 0 & 0 \\\\
44+
0 & 1 & 0 \\\\
4545
0 & 0 & 1
46-
\end{1}
47-
\right ]
46+
\\end{1}
47+
\\right ]
4848
$$)
4949
5050
@@ -380,14 +380,42 @@ mapPoints: [600.0, 900.0]
380380
| pre | 前乘,相当于矩阵的右乘, `M' = M * S` (S指为特殊矩阵) |
381381
| post | 后乘,相当于矩阵的左乘,`M' = S * M` (S指为特殊矩阵) |
382382
383-
**Matrix 相关的一些坑:**
383+
**Matrix 相关的重要知识:**
384384
385-
- 1.一开始从Canvas中获取到到Matrix并不是初始矩阵,而是经过偏移后到矩阵。
385+
- 1.一开始从Canvas中获取到到Matrix并不是初始矩阵,而是经过偏移后到矩阵,且偏移距离就是距离屏幕左上角的位置。
386386
387+
- > 这个可以用于判定View在屏幕上的绝对位置,View可以根据所处位置做出调整。
388+
389+
- 2.构造Matrix时使用的是矩阵乘法,前乘(pre)与后乘(post)结果差别很大。
390+
391+
- > 这个直接参见上一篇文章 [Matrix原理](http://www.gcssloop.com/2015/02/Matrix_Basic/) 即可。
392+
393+
- 3.受矩阵乘法影响,后面的执行的操作可能会影响到之前的操作。
394+
395+
- > 使用时需要注意构造顺序。
387396
388397
389398
### 特殊方法
390399
400+
这一类方法看似不起眼,但拿来稍微加工一下就可能制作意想不到的效果。
401+
402+
**1.setPolyToPoly**
403+
404+
```java
405+
boolean setPolyToPoly (
406+
float[] src,
407+
int srcIndex,
408+
float[] dst,
409+
int dstIndex,
410+
int pointCount)
411+
```
412+
413+
414+
415+
416+
417+
418+
391419
### 矩阵相关
392420
393421
## Matrix实用技巧

0 commit comments

Comments
 (0)