문제

Okay so I have this class

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?
    }
}

How would I realize the method GenerateLights to give me a list of rays that are inside my cone angle. Lets say the amount of rays will be some constant. Thank You.

도움이 되었습니까?

해결책

I'm no expert, but just to give you a starting point: perhaps you could put a grid perpendicular to the direction you're aiming, and only keep the rays whose angle from the direction is within coneAngle?

ASCII art:

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

imagine the grid is perpendicular to the "direction" vector.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top