Skip to content

Commit 0d195b3

Browse files
committed
Update
1 parent 274ef10 commit 0d195b3

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

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

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ public class MatrixSetPolyToPolyTest extends View {
476476
477477
我们知道`pointCount`支持点的个数为0到4个,四个一般指图形的四个角,属于最常用的一种情形,但前面几种是什么情况呢?
478478
479-
> 发布此文的时候之所以没有讲解0到3的情况,是因为前面的几种情况在实际开发中基本不会出现,除非是极其特殊的情况,~~才不是因为偷懒呢,哼。~~
479+
> 发布此文的时候之所以没有讲解0到3的情况,是因为前面的几种情况在实际开发中很少会出现, ~~才不是因为偷懒呢,哼。~~
480480
481481
482482
@@ -494,6 +494,42 @@ public class MatrixSetPolyToPolyTest extends View {
494494
495495
496496
497+
**为什么说前面几种情况在实际开发中很少出现?**
498+
499+
作为开发人员,写出来的代码出了要让机器"看懂",没有歧义之外,最重要的还是让人看懂,以方便后期的维护修改,从上边的表格中可以看出,前面的几种种情况都可以有更直观的替代方法,只有四个参数的情况下的特殊形变是没有替代方法的。
500+
501+
502+
503+
**pointCount为0**
504+
505+
pointCount为0和`reset`是等价的,而不是保持matrix不变,在最底层的实现中可以看到这样的代码:
506+
507+
```c++
508+
if (0 == count) {
509+
this->reset();
510+
return true;
511+
}
512+
```
513+
514+
515+
516+
**pointCount为1**
517+
518+
pointCount为0和`translate`是等价的,在最底层的实现中可以看到这样的代码:
519+
520+
```c++
521+
if (1 == count) {
522+
this->setTranslate(dst[0].fX - src[0].fX, dst[0].fY - src[0].fY);
523+
return true;
524+
}
525+
```
526+
527+
> 平移的距离是dst - src.
528+
529+
530+
531+
532+
497533
魔力不足,正在蓄力中...
498534
499535

0 commit comments

Comments
 (0)