Esempio n. 1
0
        public void get_pattern(ConsumerVector3 f,
                                Distribution d, bool unobstructed)
        {
            PatternConsumer de = (v2d) => { f(new Vector3(v2d.x(), v2d.y(), _curve.sagitta(v2d))); };

            // get distribution from shape
            _shape.get_pattern(de, d, unobstructed);
        }
Esempio n. 2
0
        List <TracedRay> generate_rays(
            RayTraceResults result,
            RayTraceParameters parameters,
            PointSource source,
            Element target,
            PointSource.SourceInfinityMode mode)
        {
            if (!(target is OpticalSurface))
            {
                return(new());
            }

            OpticalSurface   target_surface = (OpticalSurface)target;
            double           rlen           = parameters.get_lost_ray_length();
            Distribution     d    = parameters.get_distribution(target_surface);
            List <TracedRay> rays = new();
            ConsumerVector3  de   = (Vector3 v) =>
            {
                Vector3 r = target_surface.get_transform_to(source).transform(v); // pattern point on target surface
                Vector3 direction;
                Vector3 position;

                switch (mode)
                {
                case PointSource.SourceInfinityMode.SourceAtFiniteDistance:
                    position  = Vector3.vector3_0;
                    direction = r.normalize();
                    break;

                default:
                case PointSource.SourceInfinityMode.SourceAtInfinity:
                    direction = Vector3.vector3_001;
                    position  = new Vector3Pair(
                        target_surface.get_position(source).minus(Vector3.vector3_001.times(rlen)),
                        Vector3.vector3_001)
                                .pl_ln_intersect(new Vector3Pair(r, direction));
                    break;
                }

                foreach (SpectralLine l in source.spectrum())
                {
                    // generated rays use source coordinates
                    TracedRay ray = result.newRay(position, direction);
                    ray.set_creator(source);
                    ray.set_intensity(l.get_intensity()); // FIXME depends on distance from
                    // source and pattern density
                    ray.set_wavelen(l.get_wavelen());
                    Medium material = source.get_material();
                    if (material == null)
                    {
                        material = Air.air; // FIXME centralize as env - original uses env proxy.
                    }

                    ray.set_material(material);
                    rays.Add(ray);
                }
            };

            target_surface.get_pattern(de, d, parameters.get_unobstructed());
            return(rays);
        }