public string angleToRGB(Scientrace.Spot aCasualty, PhysicalObject3d physObj)
        {
            UnitVector inAngle = aCasualty.trace.traceline.direction;
            Scientrace.Parallelogram pg = physObj.getDistributionSurface();
            Scientrace.NonzeroVector norm = physObj.getSurfaceNormal();

            UnitVector y = pg.plane.v.toUnitVector();
            UnitVector x = null;
            try {
            x = norm.crossProduct(y).tryToUnitVector();
            } catch { throw new ZeroNonzeroVectorException("The vertical vector (plane.v) is parallel to the unit normal.");
            }
            double dx = x.dotProduct(inAngle);
            double dy = y.dotProduct(inAngle);

            double lengthFraction = Math.Sqrt((dx*dx)+(dy*dy));
            //Console.WriteLine("Length: "+lengthFraction+ " vs: "+((x*dx)+(y*dy)).length);

            double angle = Math.Atan2(dy, dx);

            return this.angleToHTML(angle, 2*Math.Asin(lengthFraction)/Math.PI);

            //physObj.getSurfaceNormal()
            //aCasualty.object3d.
            //		throw new Exception("Not yet implemented");
        }
        public string angleToRGB(Scientrace.Spot aCasualty, PhysicalObject3d physObj)
        {
            UnitVector inAngle = aCasualty.trace.traceline.direction;

            Scientrace.Parallelogram pg   = physObj.getDistributionSurface();
            Scientrace.NonzeroVector norm = physObj.getSurfaceNormal();

            UnitVector y = pg.plane.v.toUnitVector();
            UnitVector x = null;

            try {
                x = norm.crossProduct(y).tryToUnitVector();
            } catch { throw new ZeroNonzeroVectorException("The vertical vector (plane.v) is parallel to the unit normal."); }
            double dx = x.dotProduct(inAngle);
            double dy = y.dotProduct(inAngle);

            double lengthFraction = Math.Sqrt((dx * dx) + (dy * dy));
            //Console.WriteLine("Length: "+lengthFraction+ " vs: "+((x*dx)+(y*dy)).length);

            double angle = Math.Atan2(dy, dx);

            return(this.angleToHTML(angle, 2 * Math.Asin(lengthFraction) / Math.PI));

            //physObj.getSurfaceNormal()
            //aCasualty.object3d.
//		throw new Exception("Not yet implemented");
        }
        public void registerObject(XElement xe, Scientrace.PhysicalObject3d o3d)
        {
            XElement xer = xe.Element("Register");

            if (xer == null)
            {
                return;
            }
            // This one has some history which is still backwards compatible. Early versions
            // of Scientrace demanded an element called "Register" and an attribute called
            // "SolarCell" (later replaced by "Performace") to be set.
            // Nowadays, a simple "Register" attribute to the object main element will do.
            if (this.X.getXBool(xer, "SolarCell",
                                (this.X.getXBool(xer, "Performance",
                                                 (this.X.getXBool(xe, "Register", false))
                                                 ))))
            {
                Scientrace.TraceJournal.Instance.registerObjectPerformance(o3d);
            }
            //20151021: The DistributionSquare functionality has been removed as it was no longer considered useful.

            /*if (this.X.getXBool(xer.Attribute("DistributionObject"), false)) {
             *      Scientrace.TraceJournal.Instance.registerDistributionObject(o3d);
             *      } */
        }
 public string getPhotonColourForPDPSource(Scientrace.Spot casualtySpot, PDPSource pdpSource, PhysicalObject3d physObj)
 {
     switch (pdpSource) {
     case PDPSource.Wavelength: return this.wavelengthToRGB(casualtySpot.trace.wavelenght);
     case PDPSource.AngleWheel: return this.angleToRGB(casualtySpot, physObj);
     }
     throw new Exception("Unknown PDPSource: "+pdpSource);
 }
        public string getPhotonColourForPDPSource(Scientrace.Spot casualtySpot, PDPSource pdpSource, PhysicalObject3d physObj)
        {
            switch (pdpSource)
            {
            case PDPSource.Wavelength: return(this.wavelengthToRGB(casualtySpot.trace.wavelenght));

            case PDPSource.AngleWheel: return(this.angleToRGB(casualtySpot, physObj));
            }
            throw new Exception("Unknown PDPSource: " + pdpSource);
        }