当前位置: 首页 > wzjs >正文

会qt怎么做网站百度关键词排名优化

会qt怎么做网站,百度关键词排名优化,免费公司网站制作,备案号被取消 没有重新备案网站会被关闭吗理解齐次坐标系下的变换矩阵 文章目录 理解齐次坐标系下的变换矩阵1 引言2 齐次坐标系的简要介绍2.1 齐次坐标系的定义2.2 为什么需要齐次坐标系?2.3 齐次坐标系的特殊性质2.3.1 点和向量的区分2.3.2 投影变换 3 齐次坐标系下的变换矩阵3.1 二维变换矩阵平移变换缩放…

理解齐次坐标系下的变换矩阵

文章目录

  • 理解齐次坐标系下的变换矩阵
    • 1 引言
    • 2 齐次坐标系的简要介绍
      • 2.1 齐次坐标系的定义
      • 2.2 为什么需要齐次坐标系?
      • 2.3 齐次坐标系的特殊性质
        • 2.3.1 点和向量的区分
        • 2.3.2 投影变换
    • 3 齐次坐标系下的变换矩阵
      • 3.1 二维变换矩阵
        • 平移变换
        • 缩放变换
        • 旋转变换(逆时针旋转θ角度)
        • 复合变换
      • 3.2 三维变换矩阵
        • 平移变换
        • 缩放变换
        • 绕X轴旋转
        • 绕Y轴旋转
        • 绕Z轴旋转
    • 4 齐次坐标系下的变换矩阵的实际应用示例
    • 5 总结
    • 参考文献

1 引言

在计算机图形学、计算机视觉和机器人学等领域,齐次坐标系是一个极其重要的数学工具。它不仅能够统一表示平移、旋转、缩放等变换,还能够处理投影变换,使得各种几何变换可以通过矩阵乘法优雅地表示和计算。本文将深入介绍齐次坐标系的概念以及在此基础上的变换矩阵。

2 齐次坐标系的简要介绍

关于齐次坐标系及其作用的介绍,可以参考我的这一篇文章:齐次坐标系统:什么是齐次坐标?为什么要引入齐次坐标?。

2.1 齐次坐标系的定义

齐次坐标系是将n维空间映射到n+1维空间的一种方法:

  • 二维空间中的点 ( x , y ) (x, y) (x,y)在齐次坐标系中表示为 ( x , y , w ) (x, y, w) (x,y,w),其中 w ≠ 0 w \neq 0 w=0,对应的笛卡尔坐标为 ( x / w , y / w ) (x/w, y/w) (x/w,y/w)
  • 三维空间中的点 ( x , y , z ) (x, y, z) (x,y,z)在齐次坐标系中表示为 ( x , y , z , w ) (x, y, z, w) (x,y,z,w),其中 w ≠ 0 w \neq 0 w=0,对应的笛卡尔坐标为 ( x / w , y / w , z / w ) (x/w, y/w, z/w) (x/w,y/w,z/w)

通常,我们令 w = 1 w=1 w=1,即二维点表示为 ( x , y , 1 ) (x, y, 1) (x,y,1),三维点表示为 ( x , y , z , 1 ) (x, y, z, 1) (x,y,z,1)

2.2 为什么需要齐次坐标系?

在传统的笛卡尔坐标系中,我们用 ( x , y ) (x, y) (x,y)表示二维平面上的点,用 ( x , y , z ) (x, y, z) (x,y,z)表示三维空间中的点。然而,当我们需要表示平移变换时,会遇到一个问题:平移不能用线性变换(即矩阵乘法)表示。

例如,在二维空间中,点 ( x , y ) (x, y) (x,y)沿向量 ( t x , t y ) (t_x, t_y) (tx,ty)平移后的坐标为:
x ′ = x + t x y ′ = y + t y x' = x + t_x \\ y' = y + t_y x=x+txy=y+ty

这个变换包含加法操作,无法用矩阵乘法表示。为了解决这个问题,齐次坐标系应运而生。

2.3 齐次坐标系的特殊性质

2.3.1 点和向量的区分

在齐次坐标系中,点和向量可以明确区分:

  • 点: ( x , y , z , 1 ) (x, y, z, 1) (x,y,z,1)
  • 向量: ( x , y , z , 0 ) (x, y, z, 0) (x,y,z,0)

这种区分在几何计算中非常有用,因为点可以平移,而向量只能旋转和缩放。

2.3.2 投影变换

齐次坐标系最强大的特性之一是能够表示投影变换。通过适当设置 4 × 4 4 \times 4 4×4矩阵,我们可以实现透视投影、正交投影等。

例如,一个简单的透视投影矩阵可以表示为:
( 1 0 0 0 0 1 0 0 0 0 1 0 0 0 − 1 / d 0 ) \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & -1/d & 0 \end{pmatrix} 100001000011/d0000
其中d是视点到投影平面的距离。

3 齐次坐标系下的变换矩阵

注:这些变换矩阵的使用方式(对应的矩阵乘法)如下:

以在二维空间中,逆时针旋转θ角度的旋转矩阵为例:

R ( θ ) = ( cos ⁡ ( θ ) − sin ⁡ ( θ ) 0 sin ⁡ ( θ ) cos ⁡ ( θ ) 0 0 0 1 ) R(\theta) = \begin{pmatrix} \cos(\theta) & -\sin(\theta) & 0 \\ \sin(\theta) & \cos(\theta) & 0 \\ 0 & 0 & 1 \end{pmatrix} R(θ)= cos(θ)sin(θ)0sin(θ)cos(θ)0001

对于点 P = ( x , y , 1 ) T P = (x, y, 1)^T P=(x,y,1)T,旋转后的点 P ′ P' P 可以通过以下矩阵乘法计算(注意此时的 P P P矩阵是列向量):

P ′ = R ( θ ) ⋅ P = ( cos ⁡ ( θ ) − sin ⁡ ( θ ) 0 sin ⁡ ( θ ) cos ⁡ ( θ ) 0 0 0 1 ) ( x y 1 ) = ( x cos ⁡ ( θ ) − y sin ⁡ ( θ ) x sin ⁡ ( θ ) + y cos ⁡ ( θ ) 1 ) P' = R(\theta) \cdot P = \begin{pmatrix} \cos(\theta) & -\sin(\theta) & 0 \\ \sin(\theta) & \cos(\theta) & 0 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix} = \begin{pmatrix} x\cos(\theta) - y\sin(\theta) \\ x\sin(\theta) + y\cos(\theta) \\ 1 \end{pmatrix} P=R(θ)P= cos(θ)sin(θ)0sin(θ)cos(θ)0001 xy1 = xcos(θ)ysin(θ)xsin(θ)+ycos(θ)1

也可以写成(注意此时的 P P P矩阵是列向量(x, y, 1)):

P ′ = P ⋅ R ( θ ) = ( x y 1 ) ( cos ⁡ ( θ ) sin ⁡ ( θ ) 0 − sin ⁡ ( θ ) cos ⁡ ( θ ) 0 0 0 1 ) = ( x cos ⁡ ( θ ) − y sin ⁡ ( θ ) x sin ⁡ ( θ ) + y cos ⁡ ( θ ) 1 ) P' = P \cdot R(\theta) = \begin{pmatrix} x & y & 1 \end{pmatrix} \begin{pmatrix} \cos(\theta) & \sin(\theta) & 0 \\ -\sin(\theta) & \cos(\theta) & 0 \\ 0 & 0 & 1 \end{pmatrix} = \begin{pmatrix} x\cos(\theta) - y\sin(\theta) & x\sin(\theta) + y\cos(\theta) & 1 \end{pmatrix} P=PR(θ)=(xy1) cos(θ)sin(θ)0sin(θ)cos(θ)0001 =(xcos(θ)ysin(θ)xsin(θ)+ycos(θ)1)

下文中的变换矩阵均以前一种方法(即表示点的坐标的 P P P矩阵是行向量,与变换矩阵依次左乘)为例。如果采用后一种方法,即表示点的坐标的 P P P矩阵是列向量,那么变换矩阵应该转置,并且这个表示点的坐标的列向量 P P P矩阵与变换矩阵应依次右乘

3.1 二维变换矩阵

在二维齐次坐标系下,变换矩阵是 3 × 3 3 \times 3 3×3的:

平移变换

( 1 0 t x 0 1 t y 0 0 1 ) \begin{pmatrix} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \end{pmatrix} 100010txty1

缩放变换

( s x 0 0 0 s y 0 0 0 1 ) \begin{pmatrix} s_x & 0 & 0 \\ 0 & s_y & 0 \\ 0 & 0 & 1 \end{pmatrix} sx000sy0001

旋转变换(逆时针旋转θ角度)

( cos ⁡ ( θ ) − sin ⁡ ( θ ) 0 sin ⁡ ( θ ) cos ⁡ ( θ ) 0 0 0 1 ) \begin{pmatrix} \cos(\theta) & -\sin(\theta) & 0 \\ \sin(\theta) & \cos(\theta) & 0 \\ 0 & 0 & 1 \end{pmatrix} cos(θ)sin(θ)0sin(θ)cos(θ)0001

复合变换

多个变换可以通过矩阵乘法组合在一起。例如,先旋转后平移的变换矩阵为:
( 1 0 t x 0 1 t y 0 0 1 ) × ( cos ⁡ ( θ ) − sin ⁡ ( θ ) 0 sin ⁡ ( θ ) cos ⁡ ( θ ) 0 0 0 1 ) = ( cos ⁡ ( θ ) − sin ⁡ ( θ ) t x sin ⁡ ( θ ) cos ⁡ ( θ ) t y 0 0 1 ) \begin{pmatrix} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \end{pmatrix} \times \begin{pmatrix} \cos(\theta) & -\sin(\theta) & 0 \\ \sin(\theta) & \cos(\theta) & 0 \\ 0 & 0 & 1 \end{pmatrix} = \begin{pmatrix} \cos(\theta) & -\sin(\theta) & t_x \\ \sin(\theta) & \cos(\theta) & t_y \\ 0 & 0 & 1 \end{pmatrix} 100010txty1 × cos(θ)sin(θ)0sin(θ)cos(θ)0001 = cos(θ)sin(θ)0sin(θ)cos(θ)0txty1

3.2 三维变换矩阵

在三维齐次坐标系下,变换矩阵是 4 × 4 4 \times 4 4×4的:

平移变换

( 1 0 0 t x 0 1 0 t y 0 0 1 t z 0 0 0 1 ) \begin{pmatrix} 1 & 0 & 0 & t_x \\ 0 & 1 & 0 & t_y \\ 0 & 0 & 1 & t_z \\ 0 & 0 & 0 & 1 \end{pmatrix} 100001000010txtytz1

缩放变换

( s x 0 0 0 0 s y 0 0 0 0 s z 0 0 0 0 1 ) \begin{pmatrix} s_x & 0 & 0 & 0 \\ 0 & s_y & 0 & 0 \\ 0 & 0 & s_z & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix} sx0000sy0000sz00001

绕X轴旋转

( 1 0 0 0 0 cos ⁡ ( θ ) − sin ⁡ ( θ ) 0 0 sin ⁡ ( θ ) cos ⁡ ( θ ) 0 0 0 0 1 ) \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos(\theta) & -\sin(\theta) & 0 \\ 0 & \sin(\theta) & \cos(\theta) & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix} 10000cos(θ)sin(θ)00sin(θ)cos(θ)00001

绕Y轴旋转

( cos ⁡ ( θ ) 0 sin ⁡ ( θ ) 0 0 1 0 0 − sin ⁡ ( θ ) 0 cos ⁡ ( θ ) 0 0 0 0 1 ) \begin{pmatrix} \cos(\theta) & 0 & \sin(\theta) & 0 \\ 0 & 1 & 0 & 0 \\ -\sin(\theta) & 0 & \cos(\theta) & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix} cos(θ)0sin(θ)00100sin(θ)0cos(θ)00001

绕Z轴旋转

( cos ⁡ ( θ ) − sin ⁡ ( θ ) 0 0 sin ⁡ ( θ ) cos ⁡ ( θ ) 0 0 0 0 1 0 0 0 0 1 ) \begin{pmatrix} \cos(\theta) & -\sin(\theta) & 0 & 0 \\ \sin(\theta) & \cos(\theta) & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix} cos(θ)sin(θ)00sin(θ)cos(θ)0000100001

4 齐次坐标系下的变换矩阵的实际应用示例

下面是一个使用Python和NumPy实现齐次坐标变换的简单示例:

import numpy as np
import matplotlib.pyplot as plt# 定义一个2D点
point = np.array([1, 2, 1])  # 齐次坐标 (x, y, 1)# 定义变换矩阵
# 1. 平移变换 (x+2, y+3)
translation = np.array([[1, 0, 2],[0, 1, 3],[0, 0, 1]
])# 2. 旋转变换 (45度)
theta = np.radians(45)
rotation = np.array([[np.cos(theta), -np.sin(theta), 0],[np.sin(theta), np.cos(theta), 0],[0, 0, 1]
])# 3. 缩放变换 (x*2, y*2)
scaling = np.array([[2, 0, 0],[0, 2, 0],[0, 0, 1]
])# 应用变换
translated_point = translation.dot(point)
rotated_point = rotation.dot(point)
scaled_point = scaling.dot(point)# 组合变换 (先旋转,再平移)
combined = translation.dot(rotation)
combined_point = combined.dot(point)# 打印结果
print(f"原始点: ({point[0]}, {point[1]})")
print(f"平移后: ({translated_point[0]}, {translated_point[1]})")
print(f"旋转后: ({rotated_point[0]:.2f}, {rotated_point[1]:.2f})")
print(f"缩放后: ({scaled_point[0]}, {scaled_point[1]})")
print(f"组合变换后: ({combined_point[0]:.2f}, {combined_point[1]:.2f})")

5 总结

齐次坐标系是计算机图形学中的基础工具,它通过增加一个维度,使得各种变换(包括平移、旋转、缩放和投影)都可以用矩阵乘法统一表示。这种表示方法不仅数学上优雅,而且在计算上高效,特别是在需要连续应用多种变换的场景中。

理解齐次坐标系及其变换矩阵,对于从事计算机图形学、计算机视觉、机器人学等领域的开发和研究工作至关重要。通过本文的介绍,希望读者能够掌握这一强大工具的基本原理和应用方法。

参考文献

  1. Foley, J. D., Van Dam, A., Feiner, S. K., & Hughes, J. F. (1995). Computer Graphics: Principles and Practice. Addison-Wesley.
  2. Shirley, P., & Marschner, S. (2009). Fundamentals of Computer Graphics. A K Peters/CRC Press.
  3. Craig, J. J. (2004). Introduction to Robotics: Mechanics and Control. Pearson Education.

如有问题或建议,欢迎在评论区留言交流!

http://www.dtcms.com/wzjs/377486.html

相关文章:

  • 常见的网站结构有哪些口碑营销策略有哪些
  • 网站外包要注意什么网站推广软件ky99
  • 如何使用域名访问网站网站排名优化外包公司
  • 深圳建设工程交易中心网站网站建站推广
  • 注册网站要多少钱长尾关键词挖掘爱站网
  • 怎么做二十八页美食网站珠海网站建设
  • 怎么自己做H5网站企业网站设计与推广
  • 邮箱号码大全seo网站优化优化排名
  • 怎么自学做网站流量推广app
  • 上海 .net网站建设网建
  • 地方门户网站用户宁波seo优化外包公司
  • 如何把网站放到空间别人可以访问优化营商环境评价
  • 网站建设百科广州网站优化运营
  • 济宁网站建设专家如何开发微信小程序
  • 那里做一元云购网站英文站友情链接去哪里查
  • 免费虚拟主机代理网站搜索引擎优化工具
  • 青岛品牌网站制作网页设计主要做什么
  • 党建微信网站开发方案福州关键词优化平台
  • 稷山网站制作网络优化公司排名
  • 有什么做动图比较方便的网站新品推广活动方案
  • 千阳县住房和城乡建设局网站网络营销服务有哪些
  • 大作业网站建设方案stp营销战略
  • 网站提交地址超级外链推广
  • 网站关键词推广方案电脑培训机构哪个好
  • 怎样办网站做宣传软件开发外包
  • 如何对网站做渗透谷歌搜索引擎香港入口
  • 基于jsp的网站开发开题报告最近新闻热点国家大事
  • 济南网站建设公seo流量排名工具
  • 网站公司好做吗深圳互联网公司50强
  • 如何查看一个网站是不是用h5做的温州seo结算