matrix矩阵

时间:2014-10-27 17:29:12   收藏:0   阅读:227

matrix(a,b,c,d,e,f)

x’        | a c e  |     x

y’    =  | b d f  |     y

1        |  0 0 1  |    1

 

这就是矩阵的运算了,简化为公式:
x’=ax+cy+e
y’=bx+dy+f

 

css3的transform属性很好用,其实可以变换为matrix矩阵工作,只需要给abcdef附上相应的值就可以了。

比如translate(tx,ty)可以由matrix(1,0,0,1,tx,ty)转换而来,计算方法见公式
scale(sx,sy)可以由matrix(sx,0,0,sy,0,0)转变
rotate(θ)可以有matrix(cosθ,sinθ,-sinθ,cosθ,0,0)转变而来
skew(θx,θy)可以由matrix(1,tan(θy),tan(θx),1,0,0)转变过来

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!