Skip to content

Commit 4fcba0f

Browse files
committed
Update value compute
1 parent bc09c5d commit 4fcba0f

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,46 @@ isRect: false
330330
331331
**4.mapVectors**
332332
333+
测量向量。
333334
335+
``` java
336+
void mapVectors (float[] vecs)
337+
338+
void mapVectors (float[] dst, float[] src)
339+
340+
void mapVectors (float[] dst, int dstIndex, float[] src, int srcIndex, int vectorCount)
341+
```
342+
343+
`mapVectors` 与 `mapPoints` 基本上是相同的,可以直接参照上面的`mapPoints`使用方法。
344+
345+
而两者唯一的区别就是`mapVectors`不会受到位移的影响,这符合向量的定律,如果你不了解的话,请找到以前教过你的老师然后把学费要回来。
346+
347+
区别:
348+
349+
``` java
350+
float[] src = new float[]{1000, 800};
351+
float[] dst = new float[2];
352+
353+
// 构造一个matrix
354+
Matrix matrix = new Matrix();
355+
matrix.setScale(0.5f, 1f);
356+
matrix.postTranslate(100,100);
357+
358+
// 计算向量, 不受位移影响
359+
matrix.mapVectors(dst, src);
360+
Log.i(TAG, "mapVectors: "+Arrays.toString(dst));
361+
362+
// 计算点
363+
matrix.mapPoints(dst, src);
364+
Log.i(TAG, "mapPoints: "+Arrays.toString(dst));
365+
```
366+
367+
结果:
368+
369+
```
370+
mapVectors: [500.0, 800.0]
371+
mapPoints: [600.0, 900.0]
372+
```
334373
335374
### set pre 与 post
336375

0 commit comments

Comments
 (0)