2

我在 OpenGL/C++ 中编写了一个程序来跟踪一个锥体。对于我的强度计算,我需要知道表面法线。给定一个基本半径、高度和中心坐标,我如何计算表面法线?

4

2 回答 2

4

我假设您需要在给定表面上的一个点的情况下找到表面的法线。我进一步假设这是一个圆锥体,其底部朝下(-y 轴),圆锥体的点朝上(+y 轴)。如果这些条件中的任何一个不属于这种情况,我可以编辑我的答案以适合您的情况。

让我们称您在表面 P 上的点、中心坐标 C、半径 r、高度 h 和法线 N。

所有的点和向量都有三个分量(x、y、z),所以我将使用“.”来引用它们。例如,Px 是 P 的 x 分量。

首先,我们需要一个投影到从 C 到 P 的 x/z 平面上的单位向量。

Vx=Px-Cx

Vy=0

Vz=Pz-Cz

该向量具有正确的方向,但幅度大于 1。它还不是单位向量,所以我们必须相应地对其进行缩放。

m=sqrt(Vx 2 +Vz 2 )

m 现在是 V 的大小,我们将使用它来缩放 V...

Vx/=m

Vz/=m

找到法线的最终计算是......

Nx=Vx*h/r

Ny=r/h

Nz=Vz*h/r

于 2012-12-09T23:28:42.240 回答
0

If you have your Cone faced down and an opening angel (α), base at h on (+z). You can chose your co-system on the top of con. Which means that the cone is balanced on the pointy part.

In this case you can derive a general expression for the normal komponent to this surface.

Step 1:

Express the normal i spherical coordinates(e_r,e_θ,e_φ), there all components are unit vectors and θ is defined as azimuthal angel.

result --> e_θ(θ==α,φ)

if you work with som other property of this shape such as magnetization M or electric flux. One can easily trasform this i cylindrical coordinates.

Step 2:

e_θ==-sin(θ) e_z +cos(θ) e_s(φ) there θ==α.

于 2014-05-31T19:02:14.430 回答