在锥上获得正常点

时间:2015-03-20 19:04:27

标签: graphics

我正在尝试在我的光线追踪器中使用锥形基元。我得到了锥形和射线工作的交叉点。但是,我不知道如何从定义锥体的方式获得锥体的法线。 我用以下内容定义了我的锥体:

pos -- The vertex  of the cone
size -- Height of the cone
direction -- A unit vector that defines the direction of the cone
angle --  The angle of the cone

(有关更多信息,我按照Intersection of line and Cone的方式作为参考,了解它的定义方式。)

从我收集的内容中我可以使用two tangents of a point with the parametric eqn,并使用他们的交叉产品获得正常。但是我不知道如何根据我定义锥体的方式获得参数方程,以及参数方程的两个切线。

如果以某种方式有另一种方法来找到那些很棒的法线。

1 个答案:

答案 0 :(得分:0)

我最终将渐变函数应用于锥方程(x*a+y*b+z*c)^2-(a^2+b^2+c^2)(x^2+y^2+z^2)cos(t)^2其中

  1. {x,y,z} = 3d点(有问题的正常点)
  2. {a,b,c} =方向向量
  3. t =锥角
  4. 然后使用wolframalpha,这最终会给我

    • x =(2a(a x + b y + c z)-2(a ^ 2 + b ^ 2 + c ^ 2)x cos ^ 2(t))
    • y =(2 b(a x + b y + c z)-2(a ^ 2 + b ^ 2 + c ^ 2)y cos ^ 2(t))
    • z =(2 c(a x + b y + c z)-2(a ^ 2 + b ^ 2 + c ^ 2)z cos ^ 2(t))

    normal={x,y,z}