Chapter8_FundamentalsOfComputerGraphic

本文深入探讨了将3D对象映射到2D屏幕的过程,包括视图变换、正交投影和相机定位。视图变换通过刚体变换将相机置于合适位置,投影变换将3D点投影到2D视图体积内,而视口变换则将标准化图像矩形映射到实际像素坐标。此外,文章还介绍了透视投影,用于创建深度感,以及透视变换的线性有理函数特性。

个人体会

如何学会一个变换?我觉得需要关注变换前后图像的区别,物体位置、大小变了没有?坐标系位置变了没有?
由于这篇文章介绍了一系列的变换,所以要关注前一个变换的输入,因为它是后一个变换的输出。
一个变换可以分解为多个更简单的变换。对一个向量左乘上一个矩阵,相当于对其执行了某种操作。
The Camera Transformation:实际上这个变换是调整相机朝向,使其与 u v w uvw uvw 坐标系对齐。

The Orthographic Projection Transformation:将 orthographic view volume 映射到 canonical view volume。

The Viewport Transformation:将 [ − 1 , 1 ] 2 [-1,1]^2 [1,1]2 映射到 [ − 0.5 , n x + 0.5 ] × [ − 0.5 , n y + 0.5 ] [-0.5, n_x+0.5]\times[-0.5, n_y+0.5] [0.5,nx+0.5]×[0.5,ny+0.5]

Projective Transformations:用 4 维的仿射变换表示 3 维的线性变换,从而避免不能除以 z 的困扰。

Viewing

原文1:A second important use of geometric transformations is in moving objects between their 3D locations and their positions in a 2D view of the 3D world. This 3D to 2D mapping is called a viewing transformation, and it plays an important role in object-order rendering.
翻译1:几何变换的第二个重要用处是在它们的 3 维位置和他们的在 3 维世界的 2 维视图位置中移动物体。这个 3 维到 2 维的映射称之为视图变换,它在对象-顺序渲染过程中起了很重要的作用。
重点1 3 D → 2 D : v i e w t r a n s f o r m a t i o n \mathbf{3D} \rightarrow \mathbf{2D}:\quad \mathbf{view} \quad \mathbf{transformation} 3D2D:viewtransformation
   
原文2:By itself, the ability to project points from the world to the image is only good for producing wireframe renderings—renderings in which only the edges of objects are drawn, and closer surfaces do not occlude more distant surfaces (Figure 8.1). Just as a ray tracer needs to find the closest surface intersection along each viewing ray, an object-order renderer displaying solid-looking objects has to work out which of the (possibly many) surfaces drawn at any given point on the screen is closest and display only that one. In this chapter, we assume we are drawing a model consisting only of 3D line segments that are specified by the (x, y, z) coordinates of their two endpoints. Later chapters will discuss the machinery needed to produce renderings of solid surfaces.
翻译2:就其本身而言,将点从世界投影到图像的能力仅适用于生成线框渲染——在渲染中仅绘制对象的边缘,并且更近的表面不会遮挡更远的表面(图 8.1)。 就像光线追踪器需要沿着每条视线找到最近的表面交叉点一样,显示实体对象的对象顺序渲染器必须计算出在屏幕上任何给定点绘制的(可能许多)表面中的哪个最接近,并且 只显示那个。 在本章中,我们假设我们正在绘制一个仅由 3D 线段组成的模型,这些线段由它们的两个端点的 (x, y, z) 坐标指定。 后面的章节将讨论生成实体表面渲染所需的机制。
重点 2 :This chapter focus on wireframe renderings instead of solid surface rendering.
   
在这里插入图片描述
   

8.1 Viewing Transformations

原文 3 :The viewing transformation has the job of mapping 3D locations, represented as (x, y, z) coordinates in the canonical coordinate system, to coordinates in the image, expressed in units of pixels. It is a complicated beast that depends on many different things, including the camera position and orientation, the type of projection, the field of view, and the resolution of the image. As with all complicated transformations, it is best approached by breaking it up into a product of several simpler transformations. Most graphics systems do this by using a sequence of three transformations:

  • A camera transformation or eye transformation, which is a rigid body transformation that places the camera at the origin in a convenient orientation. It depends only on the position and orientation, or pose, of the camera.
  • A projection transformation, which projects points from camera space so that all visible points fall in the range −1 to 1 in x and y. It depends only on the type of projection desired.
  • A viewport transformation or windowing transformation, which maps this unit image rectangle to the desired rectangle in pixel coordinates. It depends only on the size and position of the output image.

翻译 3 :视图变换的任务是将以在典范坐标系中(x,y,z)表示的 3 维坐标,映射到在图像中的坐标系,以像素作单位表示。这是一个复杂的东西,它取决于许多不同的东西,包括相机的位置和朝向,投影的类型,视野和图像的分辨率。对于所有复杂的转换,最好的方法是将其分解为几个更简单的转换的乘积。大多数图形系统通过使用三个转换序列来实现这一点:

  • 一个相机变换或眼睛变换,这是一个刚体变换将相机以一个方便的方向放在原点。它只取决于相机的位置和方向,或位姿。
  • 投影变换,从相机空间投射点,使所有可见点都落在x 和 y 的 −1 到 1 范围内。它只取决于所需的投影类型
  • 视口转换或窗口转换,它将这个单元图像矩形映射到像素坐标中所需的矩形。它只取决于输出图像的大小和位置。
       
    为了便于描述过程的各个阶段(图8.2),我们对这些转换的输入和输出坐标系进行了命名。
    在这里插入图片描述
       
    原文 4 :The camera transformation converts points in canonical coordinates (or world space) to camera coordinates or places them in camera space. The projection transformation moves points from camera space to the canonical view volume. Finally, the viewport transformation maps the canonical view volume to screen space.
    Each of these transformations is individually quite simple. We’ll discuss them in detail for the orthographic case beginning with the viewport transformation and then cover the changes required to support perspective projection.
       

8.1.1 The Viewport Transformation

The word “canonical” crops up again-it means something arbitrarily chosen for convenience.
For instance, the unit circle could be called the “canonical circle”.
翻译:“规范”这个词又出现了——它指的是为了方便而随意选择的东西。
例如,单位圆可以被称为“规范圆”。
在这里插入图片描述

原文 5
在这里插入图片描述
我们从一个问题开始,这个问题的解决方案将在任何视图条件下重复使用。我们假设我们想要看到的几何是在规范视图体里。我们希望以一个正交相机沿着 -z 轴观察。规范视图体是包含了所有某种 3 维点的立方体。如图8.3所示,这些 3 维点的笛卡尔坐标都在 -1与+1之间,即
( x , y , z ) ∈ [ − 1 , 1 ] 3 (x,y,z)\in[-1,1]^3 (x,y,z)[1,1]3
重点来了!!!!
我们将 x = − 1 x=-1 x=1 投影到屏幕的左侧, x = + 1 x=+1 x=+1 投影到屏幕的右侧, y = − 1 y=-1 y=1 投影到屏幕的底端, y = + 1 y=+1 y=+1 投影到屏幕的顶端。
回忆来自第三章的针对像素坐标的传统:
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

每个像素“拥有”一个在整数坐标的单位正方形;图像边界与像素中心有半个单位的 overshoot;最小的像素中心坐标是(0,0)。如果我们画的图像有 n x × n y n_x\times n_y nx×ny像素,我们需要将正方形 [ − 1 , 1 ] [-1,1] [1,1] 映射到 [ − 0.5 , n x − 0.5 ] × [ − 0.5 , n y − 0.5 ] [-0.5,n_x-0.5] \times [-0.5,n_y-0.5] [0.5,nx0.5]×[0.5,ny0.5]

目前,我们假设所有需要画的线段是完全在规范视图体内。过后,我们会放松假设当我们讨论 clipping 的时候。
在这里插入图片描述

注意上图,说了是要将
[ − 1 , 1 ] 2 [-1,1]^2 [1,1]2
映射到
[ − 0.5 , n x − 0.5 ] × [ − 0.5 , n y − 0.5 ] [-0.5,n_x-0.5]\times [-0.5,n_y-0.5] [0.5,nx0.5]×[0.5,ny0.5]
这个结果可以用等式 (8.1)来验证,当 x c a n o n i c a l = − 1 o r 1 x_{canonical}=-1\quad or\quad 1 xcanonical=1or1时,结果符合。
在这里插入图片描述

8.1.2 The Orthographic Projection Transformation

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

注意,下图中的式(8.3)在下面会介绍!!!
下图中提到 orthographic transform 是将
o r t h o g r a p h i c v i e w v o l u m e orthographic\quad view \quad volume orthographicviewvolume
映射到 c a n o n i c a l v i e w v o l u m e canonical \quad view \quad volume canonicalviewvolume
而,canonical view volume 在上图 8.3 中有介绍。
在这里插入图片描述

在这里插入图片描述
注意,上面所说的 equation(7.7)如下:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

8.1.3 The Camera Transformation

实际上这个变换是调整相机朝向,使其与 u v w uvw uvw 坐标系对齐。
先阅读博主这两篇 单/二向量构造正交向量基底坐标系变换有利于理解。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

下图中说明了,要将坐标系 x y z − xyz- xyz
转换到 u v w − uvw- uvw坐标系。

在这里插入图片描述
上面构造 w , u , v \mathbf{w},\mathbf{u},\mathbf{v} w,u,v 的方法来自博文
下面变换矩阵来自坐标系变换
在这里插入图片描述
在这里插入图片描述

8.2 Projective Transformations

透视(perspective)的一个关键性质是:针对眼镜在原点,视线沿着负z轴看地情况,一个物体的大小在屏幕上与 1 / z 1/z 1/z等比例放缩。即
y s = d z y y_s = \frac{d}{z}y ys=zdy
图 8.8 很好地展示出了这个性质
在这里插入图片描述
其中, y y y 是空间中三维点沿着 y y y 轴的距离, y s y_s y

要解决在 `/home/ls/dev1/chapter3_ws/install/chapter3_tutorials/share/chapter3_tutorials` 包的共享目录中找不到 `example4_5.launch` 文件的问题,可以按以下步骤排查和解决: ### 检查文件是否存在于源码目录 通常,ROS 包在编译后会将 `launch` 文件等资源安装到共享目录。首先需要确认该文件是否存在于源码目录中。一般 `launch` 文件会存放在 `launch` 子目录下,使用以下命令检查: ```bash ls /home/ls/dev1/chapter3_ws/src/chapter3_tutorials/launch ``` 如果文件不存在,可能是没有正确编写或者放置该 `launch` 文件。 ### 检查编译配置 确保 `CMakeLists.txt` 文件中正确配置了 `launch` 文件的安装规则。在 `CMakeLists.txt` 中应该有类似如下的内容: ```cmake install(DIRECTORY launch/ DESTINATION share/${PROJECT_NAME} FILES_MATCHING PATTERN "*.launch" ) ``` 如果没有这部分内容,需要添加进去。 ### 重新编译工作空间 在修改了 `CMakeLists.txt` 后,需要重新编译工作空间,使用以下命令: ```bash cd /home/ls/dev1/chapter3_ws catkin_make ``` 或者使用 `catkin build`(如果使用 `catkin_tools`): ```bash cd /home/ls/dev1/chapter3_ws catkin build ``` ### 检查环境变量 确保 ROS 环境变量正确设置,每次打开新的终端都需要重新加载环境变量: ```bash source /home/ls/dev1/chapter3_ws/devel/setup.bash ``` ### 检查文件权限 确保文件权限允许被复制到共享目录。可以使用以下命令修改文件权限: ```bash chmod +x /home/ls/dev1/chapter3_ws/src/chapter3_tutorials/launch/example4_5.launch ``` ### 检查安装目录 再次确认文件是否已经被正确安装到共享目录: ```bash ls /home/ls/dev1/chapter3_ws/install/chapter3_tutorials/share/chapter3_tutorials ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

培之

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值