来自光源光线追踪的光的方向

时间:2013-07-20 00:15:17

标签: c# graphics geometry raytracing

好的,我有这个课程

public sealed class LightSource
{
    public readonly Point3D Source;
    public readonly Point3D Direction;

    public readonly float ConeAngle;

    public List<Ray> Lights { get; private set; }

    public const double MaxRadian = 2.0 * Math.PI;

    public LightSource(Point3D source, Point3D direction, float coneAngle)
    {
        this.Source = source;
        this.Direction = direction;

        if (coneAngle <= 0 || coneAngle > LightSource.MaxRadian)
        {
            throw new ArgumentException("coneAngle <= 0 || coneAngle > LightSource.MaxRadian");
        }

        this.ConeAngle = coneAngle;
        this.Lights = LightSource.GenerateLights(this.Source, this.Direction, this.ConeAngle);
    }

    public static List<Ray> GenerateLights(Point3D source, Point3D direction, float coneAngle)
    {
        //How would i do this?
    }
}

我如何实现GenerateLights方法,以便为我提供锥角内的光线列表。 让我们说光线的数量会有些不变。 谢谢。

1 个答案:

答案 0 :(得分:1)

我不是专家,只是为了给你一个起点:或许你可以将一个网格垂直于你瞄准的方向,并且只保留与方向的角度在coneAngle之内的光线?

ASCII艺术:

                                      +--+--+
                                      |  |  |
                                      +--+--+
                     direction        |  |  |    
staring point ----------------------> +--+--+
                                      |  |  |
                                      +--+--+
                                      |  |  |  
                                      +--+--+

想象网格垂直于“方向”向量。