平面图形原理总结(6):坐标变换

前言

本篇总结与之前的总结不太一样,与图形无关,是关于坐标变换的总结,主要使用矩阵计算完成,同样可以自行阅读参考文献了解,以下是本人的自行总结内容。

参考文献:《计算机图形学——用OpenGL实现(第2版)》 清华大学出版社

矩阵表示向量

我们可以用矩阵去表示一个点的坐标或平面向量,表示方法如下 Q = [ x y 1 ] = [ x y 1 ] T Q = \begin{gathered} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} \end{gathered} =\begin{gathered} \begin{bmatrix} x & y & 1 \end{bmatrix} \end{gathered} ^ T Q=xy1=[xy1]T*最后的1是为了方便计算拓展的

平移

假设点 Q Q Q要按向量 P P P做平移,结果为 S S S,可以表示为 S = [ S x S y 1 ] = [ 1 0 P x 0 1 P y 0 0 1 ] [ Q x Q y 1 ] = [ Q x + P x Q y + P y 1 ] S = \begin{gathered} \begin{bmatrix} S_x \\ S_y \\ 1 \end{bmatrix} \end{gathered} = \begin{gathered} \begin{bmatrix} 1 & 0 & P_x \\ 0 & 1 & P_y \\ 0 & 0 & 1 \end{bmatrix} \end{gathered} \begin{gathered} \begin{bmatrix} Q_x \\ Q_y \\ 1 \end{bmatrix} \end{gathered} = \begin{gathered} \begin{bmatrix} Q_x + P_x \\ Q_y + P_y \\ 1 \end{bmatrix} \end{gathered} S=SxSy1=100010PxPy1QxQy1=Qx+PxQy+Py1

缩放

假设向量 Q Q Q P x P_x Px P y P_y Py的缩放,结果为 S S S S = [ S x S y 1 ] = [ P x 0 0 0 P y 0 0 0 1 ] [ Q x Q y 1 ] = [ Q x P x Q y P y 1 ] S = \begin{gathered} \begin{bmatrix} S_x \\ S_y \\ 1 \end{bmatrix} \end{gathered} = \begin{gathered} \begin{bmatrix} P_x & 0 & 0 \\ 0 & P_y & 0 \\ 0 & 0 & 1 \end{bmatrix} \end{gathered} \begin{gathered} \begin{bmatrix} Q_x \\ Q_y \\ 1 \end{bmatrix} \end{gathered} = \begin{gathered} \begin{bmatrix} Q_xP_x \\ Q_yP_y \\ 1 \end{bmatrix} \end{gathered} S=SxSy1=Px00

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值