Matrix的前乘和后乘不太明白?
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Documentation
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- android, java
- Domain
- computer-graphics, mobile
Research direction
Start with the two snippets and the Android Matrix calls shown: postRotate, postTranslate, preTranslate, and PathMeasure.getMatrix. Compare their transformation order and explain why the two approaches use different multiplication directions. Done means a clear explanation grounded in the displayed examples; no file or test is identified in the issue.
Written by the indexing model from the issue text.
Description
measure.getPosTan(measure.getLength() * currentValue, pos, tan); // 获取当前位置的坐标以及趋势
mMatrix.reset(); // 重置Matrix
float degrees = (float) (Math.atan2(tan[1], tan[0]) * 180.0 / Math.PI); // 计算图片旋转角度
mMatrix.postRotate(degrees, mBitmap.getWidth() / 2, mBitmap.getHeight() / 2); // 旋转图片
mMatrix.postTranslate(pos[0] - mBitmap.getWidth() / 2, pos[1] - mBitmap.getHeight() / 2); // 将图片绘制中心调整到与当前点重合
这是第一种方案,
// 获取当前位置的坐标以及趋势的矩阵
measure.getMatrix(measure.getLength() * currentValue, mMatrix, PathMeasure.TANGENT_MATRIX_FLAG | PathMeasure.POSITION_MATRIX_FLAG);
mMatrix.preTranslate(-mBitmap.getWidth() / 2, -mBitmap.getHeight() / 2); // <-- 将图片绘制中心调整到与当前点重合(注意:此处是前乘pre)
这是第二种方案,为什么第一种是用的后乘,第二种用的是前乘,具体看了那个matrix的原理还是不太明白?可以具体讲讲吗?
- Dominant language
- Java
- Stars
- 9.3k
- Forks
- 2.1k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from GcsSloop/AndroidNote
-
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
GcsSloop/AndroidNote#116 ·
-
安卓 Open
Difficulty 5/5 Over a week Newbie friendliness 10/100
GcsSloop/AndroidNote#115 ·
-
章节缺失:安卓自定义View进阶 Open
Difficulty 3/5 1-2 days Newbie friendliness 55/100
GcsSloop/AndroidNote#114 ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 55/100
GcsSloop/AndroidNote#111 · 2 reactions ·
-
博客有几篇打不开了 Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
GcsSloop/AndroidNote#110 ·
All issues in GcsSloop/AndroidNote
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
elastic/gradle-plugins#157 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
cryptomator/hub#497 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
johanhaleby/occurrent#1120 ·