简体   繁体   English

使用转换矩阵将圆柱体转换为圆锥体

[英]Converting a cylinder into a cone using transformation matrix

Working on my OpenGL ES 2.0 based graphics engine I have the following mathematical problem: 在基于OpenGL ES 2.0的图形引擎上工作时,我遇到以下数学问题:

Using the algorithm for creating cylinders described here http://paulbourke.net/geometry/circlesphere/ one can create a generic cylinder mesh. 使用此处描述的创建圆柱体的算法http://paulbourke.net/geometry/circlesphere/可以创建通用圆柱体网格。 I use only one cylinder mesh for all my cylinders in my application. 在我的应用程序中,我对所有圆柱体仅使用一个圆柱体网格。 Trough scaling of the cylinder it is possible to create new cylinders with different radius and height without altering the standard cylinder mesh (r=1,h=1). 通过圆柱体的按比例缩放,可以创建具有不同半径和高度的新圆柱体,而无需更改标准圆柱体网格(r = 1,h = 1)。

For cones I currently create another mesh, but I had the idea that it must be somehow possible to transform a cylinder into a cone using matrix manipulation. 对于圆锥体,我目前创建了另一个网格,但是我有一个想法,那就是必须可以使用矩阵操纵将圆柱体转化为圆锥体。 Ideally it should be possible to create also a cylinder with a specified r1 and r2 (for the standard mesh r1=r2=1). 理想情况下,应该也可以创建一个具有指定r1和r2的圆柱体(对于标准网格r1 = r2 = 1)。

Any ideas how this could be possible ? 任何想法这怎么可能? I thought about a perspective matrix, but I was not successful. 我想到了一个透视矩阵,但没有成功。

Technically is is possible to make a truncated cone from a cylinder using projection transformation. 从技术上讲,可以使用投影变换从圆柱体制作截锥。 But you must consider that projection maps vertices in to normalized device coordinates (ranged from -1.0 to 1.0). 但是您必须考虑到投影将顶点映射到规范化的设备坐标(范围从-1.0到1.0)。 Moreover the projection transform may be not enough in case when you define your shape out of identity frustum, so you will have to use additional camera transformation as well. 此外,如果您用视锥台面来定义形状,则投影变换可能还不够,因此您还必须使用其他相机变换。

Actually, you can try to bake (somehow) your main camera transformation & projection. 实际上,您可以尝试烘烤(以某种方式)您的主相机转换和投影。 Just place your cylinder at the certer of view area, orient its Y axis along Z axis of camera, set up appropriate FOV and bake all the transformations (including world transformation of cylinder). 只需将圆柱体放置在查看区域的中心,将其Y轴对准相机的Z轴,设置适当的FOV并烘烤所有变换(包括圆柱体的世界变换)即可。 By multiplying all these matrices you will receive ransformation of cylinder in to a cone in normalized device coordinates. 通过将所有这些矩阵相乘,您将获得圆柱体在标准化设备坐标中的变形为圆锥体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM