1

好的,所以我有这门课

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 方法来给我一个在我的锥角内的光线列表。可以说光线的数量是恒定的。谢谢你。

4

1 回答 1

1

我不是专家,只是给你一个起点:也许你可以把一个网格垂直于你瞄准的方向,只保留与该方向的角度在锥角范围内的光线?

ASCII艺术:

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

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

于 2013-07-20T00:42:36.323 回答