示例#1
0
		public Trace getReflectTrace(double offset) {
			// If the trace has ended due to total absorption, there's no reflection.
			if (this.total_absorption) return null;

			// Construct the new trace line
			Scientrace.Line reflect_line = new Scientrace.Line(this.interaction_loc + (this.dir_r.toVector()*offset), this.dir_r);

			double new_intensity = (this.intensity_after_absorption/this.intensity_in) *
						(Math.Pow(this.amp_rs,2) + Math.Pow(this.amp_rp,2));

			// Sometimes, this new intensity is to small to care about. Return null.	
			if (new_intensity <= MainClass.SIGNIFICANTLY_SMALL) {
				//Console.WriteLine("New intensity is: "+new_intensity+" is:"+this.amp_is+" ip:"+this.amp_ip+" ts:"+this.amp_ts+" tp:"+this.amp_tp);
				return null;
				}

			Scientrace.Trace reflect_trace = 
					trace_in.fork(reflect_line, (this.dir_s.toVector()*this.amp_rs), (this.dir_rp.toVector()*this.amp_rp), 
									new_intensity, (this.total_internal_reflection?"_fr":"_r"));

			// Remain within the same object / space
			reflect_trace.currentObject = this.trace_in.currentObject;

			// Don't bother with empty traces.
			if (reflect_trace.isEmpty()) return null;

			return reflect_trace;
			}
示例#2
0
        }         // end func. redirect

        public List <Scientrace.Trace> partialReflectRefract(Scientrace.Object3d fromObject3d, Scientrace.Object3d toObject3d,
                                                             Scientrace.Intersection intersection, UnitVector surfaceNormal)
        {
            /*double oldrefindex = fromObject3d.materialproperties.refractiveindex(this);
             * double newrefindex = toObject3d.materialproperties.refractiveindex(this);*/
            List <Scientrace.Trace> newTraces = new List <Trace>();

            Scientrace.Trace refractTrace = this.fork("_pr");

            refractTrace.currentObject           = toObject3d;
            refractTrace.traceline.startingpoint = intersection.enter.loc;

            Scientrace.UnitVector normal = intersection.enter.flatshape.plane.getNorm()
                                           .orientedAgainst(this.traceline.direction)
                                           .tryToUnitVector();
            // Evaluate absorption by toObject3d
            refractTrace.absorpByObject(toObject3d, normal, fromObject3d);
            if (refractTrace.isEmpty())
            {
                newTraces.Add(refractTrace);
                return(newTraces);
            }

            // CHECK whether (partial) reflection occurs...
            if ((toObject3d.materialproperties.reflects) || ((intersection.leaving) && (fromObject3d.materialproperties.reflects)))
            {
                //double refcoef = toObject3d.materialproperties.reflection(refractTrace, surfaceNormal, this.currentObject);
                double refcoef = toObject3d.materialproperties.reflection(refractTrace, surfaceNormal, fromObject3d.materialproperties);

                Scientrace.Trace reflectTrace = refractTrace.fork("_R");         //.clone();	reflectrace.nodecount++;
                reflectTrace.intensity = refractTrace.intensity * refcoef;
                //intensity shouldn't spawn nor disappear here
                refractTrace.intensity = refractTrace.intensity - reflectTrace.intensity;
                //Scientrace.Spot normspot = new Scientrace.Spot(norm.toLocation()+intersection.enter.loc, null, 1);

                //CHANGED 20131030
                //reflectrace.traceline = newtrace.reflectAt(intersection.enter.flatshape.plane);
                reflectTrace.traceline = refractTrace.reflectLineAbout(reflectTrace.traceline, surfaceNormal);

                //ADDED @ 20130122: the parial internal reflected trace should have the current object as oldobject.
                reflectTrace.currentObject = this.currentObject;         //CURRENT OBJECT DOES NOT CHANGE FOR (partial)INTERNAL REFLECTION!
                newTraces.Add(reflectTrace);
            }

            this.initCreatedRefractTrace(refractTrace, surfaceNormal, fromObject3d, toObject3d);
            newTraces.Add(refractTrace);
            return(newTraces);
        }         // end func partialReflectRefract
示例#3
0
		public Trace getRefractTrace(double offset) {
			// If the trace has ended due to total absorption, there's no either.
			if (this.total_absorption) return null;

			// At total internel reflection, there's no refraction either (statements split up for readability purposes).
			if (this.total_internal_reflection) return null;

			Scientrace.Line refract_line = new Scientrace.Line(this.interaction_loc + (this.dir_t.toVector()*offset), this.dir_t);

			double refr_intensity = (this.intensity_after_absorption/this.intensity_in) *
						((Math.Pow(this.amp_is,2) + Math.Pow(this.amp_ip,2))-(Math.Pow(this.amp_rs,2) + Math.Pow(this.amp_rp,2)) );

			Scientrace.Trace refract_trace = 
					trace_in.fork(refract_line, (this.dir_s.toVector()*this.amp_ts), (this.dir_tp.toVector()*this.amp_tp), 
									refr_intensity, "_t");
			refract_trace.currentObject = this.object_to;

			// Don't bother with empty traces.
			if (refract_trace.isEmpty()) return null;

			return refract_trace;
			}