表面垂直于锥体 [英] surface normal to a cone
问题描述
我假设您需要找到表面上的点的法线。我进一步假定这是一个锥体,其基座朝下(-y轴),锥体的尖端指向(+ y轴)。如果这些情况中的任何一种情况都不是这样,我可以编辑我的答案以适应您的情况。
让我们称您的点P为中心坐标C,半径r,高度h和法线N.所有的点和矢量都有三个分量(x,y,z),所以我会参考这些用一个 。。例如Px是P的x分量。首先,我们需要投影到x / z平面上的单位向量,它指向C到P。
> Vx = Px-Cx Vz = Pz-Cz 这个向量有正确的方向,但是幅度大于1。它不是一个单位向量,所以我们必须相应地进行缩放。 Vx / = m Vz / = m 寻找正常的最终计算结果是.. 。 Im writing a program in OpenGL/C++ to ray trace a cone.For my intensity calculations I need to know the surface normal.Given a base radius,height and centre coordinates,how do I calculate the surface normal? I am supposing that you need to find the normal to the surface given a point on the surface. I am further assuming that this is a cone oriented such that the base is facing down (-y axis) and the point of the cone points up (+y axis). If any of these conditions are not the case, I can edit my answer to fit your situation. Let us call your point on the surface P, the center coordinates C, the radius r, the height h, and the normal N. All points and vectors have three components (x, y, z), so I will refer to these by using a ".". For example P.x is the x component of P. First, we need a unit vector projected on to the x/z plane which points from C to P. V.x=P.x-C.x V.y=0 V.z=P.z-C.z This vector has the correct direction, but the magnitude is greater than one. It is not a unit vector yet, so we must scale it accordingly. m=sqrt(V.x2+V.z2) m is now the magnitude of V, which we will use to scale V... V.x/=m V.z/=m The final calculations to find the normal are... N.x=V.x*h/r N.y=r/h N.z=V.z*h/r 这篇关于表面垂直于锥体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
m = sqrt(Vx <2> + Vz <2> <2> / sup>)
现在是V的大小,我们将用它来缩放V ......
Nx = Vx * h / r
Ny = r / h