A Personal Understanding to Matrix Transformation in Graphics
A Personal Understanding to Matrix Transformation in Graphics
-------------------------------------------------------------
Matrix Transformation is a vital important concept for people who are at their beginning of learning Graphics. And this concept usually get hard to learn, especially from a mathematical perspective. This article, however, is not going to elaborate such a theory by an arithmetic way. Instead I'll just focus on a single topic and talk about what I got from that.
What I'm going to talk is "how to understand that more than one matrix integrate into one result matrix which will then be applied to a vertex to make it transformed."
=================
Let's start from the simplest case, there's only one matrix applied to a vertex, which is written like this:
Va = [M1] * Vb
It's obvious that "Vb" is transformed to "Va" through the matrix "[M1]". But on the other side, we can think this formula from another meaning, which is in fact the essential idea in this article. Before explaining the idea, let's give a little background knowledge first : the default coordinate in which we're drawing objects is actually a kind of matrix and let's call it "[M0]" for example. With this hidden matrix exposed out, we can replace the formula as this :
Va = [M0] * [M1] * Vb
Now the idea comes. We can see the representation as that the default coordinate(matrix) "[M0]" is transformed by the other matrix "[M1]" and turned into a new coordinate, and then, "Vb" is just drawn at the location as it is, but in this new coordinate. the value of "Va" represents the location of "Vb" where we look it from the default coordinate("[M0]").
So briefly speaking, There are two understandings to the same formula, just from two directions opposed to each other.
---------------> (a)
Va = [M0] * [M1] * Vb
<--------------- (b)
(a) stands at the "coordinate"'s view to see the transformation. A coordinate turns into others one by one from left to right side, and in the final result coordinate, the vertex is drawn to the location where it's value reflects.
And (b) see the transformation standing from the "vertex"'s view. A vertex is applied by a matrix and turns into another vertex with the different location. And the new vertex continues the transformation until the last matrix is applied to it. And eventually we draw this result vertex under the default coordinate ("[M0]").
Both thoughts get the same result. "Va", the left side of the equation, represents the original "Vb" is transformed to a new location where now "Va" lies in the default coordinate "[M0]". This is a good example showing "consider the same one thing from more than one aspects".
=================
It's time I give a practical case using this philosophy now, still a simple case, though. Suppose there is an arbitrary object composed of vertices(ex. a triangle with 3 vertices) in the default coordinate "[M0]". What if we want to firstly move it to somewhere, and secondly make it self-rotated, which means rotate around its own axes?
Let's break this question down. Actually our question include two transformations, MOVE and ROTATE, each can be represented by a matrix. we'll give them a name respectively, "[T]" for MOVE("Translation") and "[R]" for ROTATE("Rotation"). We know that these two matrices will be integrate to one final matrix and be applied to the object vertices, but what's the sequence of mixing? The different order, results in the different effect. So now we touched the core the question.
The answer is simple. If we adopt the idea (a), The order is alike with the way we describes the requirement. First we move the coordinate to somewhere and then rotate the coordinate to some angles. And at last we draw the object on that transformed coordinate. While if we adopt the idea (b), what we should do is to rotate the object first and move this rotated object to somewhere we're aiming on the unchanged and default matrix. Both formulas are same:
---------------> (a)
OBJa = [T] * [R] * OBJb
<--------------- (b)
=================
A little advanced example enhancing the above case is to take the "Camera View Transformation" into the consideration. We know "Camera View Transformation" is also a kind of matrix and so it can be thought as such. I don't want to go to the details too much here except only a note that the movement relationship between a camera and objects is relative. If the camera moves forward 10 steps, this also means the whole objects in the scene move backward 10 steps with the camera keeps unmoved.
Since what we're transforming is objects rather than the camera, we should take the inversed matrix of cameras' as the transforming matrix, we call it "Inv([C])", for example. The formula finally looks like this :
------------------------> (a)
OBJa = Inv([C]) * [T] * [R] * OBJb
<------------------------ (b)
A Personal Understanding to Matrix Transformation in Graphics的更多相关文章
- The history of programming languages.(transshipment) + Personal understanding and prediction
To finish this week's homework that introduce the history of programming languages , I surf the inte ...
- Matrix Transformation codechef 数学题
https://www.codechef.com/problems/MTRNSFRM 我只能说codechef的题好劲爆,这题居然是easy的题,太可怕了.而且还有一点就是codechef的题解很难看 ...
- android.graphics.Matrix
Matrix类包含了一个3x3的矩阵用来改变坐标,它没有一个构造器来初始化它里边的内容,所以创建实例后需要调用reset()方法生成一个标准matrix,或者调用set..一类的函数,比如setTra ...
- [Android]android.graphics.Camera实现图像的旋转、缩放,配合Matrix实现图像的倾斜
android.graphics.Camera可以对图像执行一些比较复杂的操作,诸如旋转与绽放,与Matrix可实现图像的倾斜. 个人总结Camera与Matrix的一些区别如下: Camera的ro ...
- Matrix: android 中的Matrix (android.graphics.Matrix) (转)
本篇博客主要讲解一下如何处理对一个Bitmap对象进行处理,包括:缩放.旋转.位移.倾斜等.在最后将以一个简单的Demo来演示图片特效的变换. 1. Matrix概述 对于一个图片变换的处理,需要Ma ...
- UNITY_MATRIX_IT_MV[Matrix] (转载)
转载 http://blog.csdn.net/cubesky/article/details/38682975 前面发了一篇关于unity Matrix的文章. http://blog.csdn.n ...
- 【转】2D动画:view的Matrix
Matrix,中文里叫矩阵,高等数学里有介绍,在图像处理方面,主要是用于平面的缩放.平移.旋转等操作. 首先介绍一下矩阵运算.加法和减法就不用说了,太简单了,对应位相加就好.图像处理,主要用到的是乘法 ...
- UNITY_MATRIX_IT_MV[Matrix]
http://blog.csdn.net/cubesky/article/details/38682975 前面发了一篇关于unity Matrix的文章. http://blog.csdn.NET/ ...
- Matrix(单点移动,多点缩放)
package cn.iris.matrixapi; import android.app.Activity; import android.graphics.Matrix; import andro ...
随机推荐
- noip第20课作业
1. 评学习小标兵 [问题描述] 东东所在的班级有 N 名同学,期末考试进行了数学.语文.英语.地理四门功课的测试.班主任要将这 N 名学生中总分前三名定为本学期的“学习小标兵”.现在给出这N 名学生 ...
- 【转】sql递归查询问题
原文链接地址http://www.cnblogs.com/sweting/archive/2009/06/08/1498483.html 在工作中遇到一个问题,是需要sql递归查询的.不懂,于是到cs ...
- Hdu1205 吃糖果 2017-06-29 14:26 24人阅读 评论(0) 收藏
吃糖果 Problem Description HOHO,终于从Speakless手上赢走了所有的糖果,是Gardon吃糖果时有个特殊的癖好,就是不喜欢将一样的糖果放在一起吃,喜欢先吃一种,下一次吃另 ...
- Strom开发配置手册
一:Storm集群搭建 1.本次开发使用的是storm0.9.3 2.Storm0.9.3集群搭建: 1)storm集群角色包含集群主节点Nimbus:集群从节点Supervisor 2)集群安装:先 ...
- iOS笔记之UIKit_UIButton
//UIButton的基本属性 _btn = [UIButton buttonWithType:UIButtonTypeCustom]; _btn.frame = CGRectMake(0, 200, ...
- map 小模板~~~ 写的不好 继续添加
#include<map>#include<string.h>#include<iostream>using namespace std; int main(){ ...
- css3的帧动画
概述 前几天刚好看到一个用了CSS3帧动画的页面,对它非常感兴趣,就研究了一下,记录在下面,供以后开发时参考,相信对其他人也有用. PS:以后别人问我用过什么CSS3属性的时候,我也可以不用说常见的a ...
- Postgres 的 Array 类型
mysql 不支持 Array 类型 一.Postgres 原生SQL 适用场景:可以用于实现贴标签功能 1.定义 CREATE TABLE "Students" ( name V ...
- ThinkPHP5代码执行的简单分析
漏洞影响版本: ThinkPHP 5.0.5-5.0.22 ThinkPHP 5.1.0-5.1.30 漏洞复现: 一.mac的debug环境搭建. 一键化环境搭建工具: mamp pro ,调试工具 ...
- 爬虫 解码gb1312类型
今天我爬虫的时候竟然遇见了网页编码为gb1312类型的网站 , 不是平常的utf-8 遇到这种类型的时候忽视它是最好的办法 ① respond.content.decode('gb18030','i ...