//length inherited from Prism
 public CircularPrism(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops, Scientrace.Location loc, Scientrace.NonzeroVector width, Scientrace.NonzeroVector height, Scientrace.NonzeroVector length) : base(parent, mprops)
 {
     this.loc    = loc;
     this.width  = width;
     this.height = (height.tryToUnitVector()) * width.length;
     this.length = length;
 }
 //length inherited from Prism
 public RectangularPrism(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops, Scientrace.Location loc, Scientrace.NonzeroVector width, Scientrace.NonzeroVector height, Scientrace.NonzeroVector length) : base(parent, mprops)
 {
     this.loc    = loc;
     this.width  = width;
     this.length = length;
     this.height = height;
 }
 public InfiniteCylinderBorder(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops,
                               Scientrace.Location loc, Scientrace.UnitVector direction, double radius) : base(parent, mprops)
 {
     this.direction = direction;
     this.radius    = radius;
     this.loc       = loc;
 }
Beispiel #4
0
        public Scientrace.Object3dEnvironment parseXEnv(XElement xenv)
        {
            //Create the collection itself with its properties first.
            Scientrace.Object3dEnvironment retenv;

            // Creating "the entire object-space"
            double env_radius = this.X.getXDouble(xenv, "Radius", -1);

            if (env_radius == -1)
            {
                Console.WriteLine("Warning: ObjectEnvironment has no radius attribute. Using 16 as an arbitrary default. You might want to change this.");
                env_radius = 16;
            }
            string environment_material_id = this.X.getXStringByName(xenv, "Environment", "air");

            ScientraceXMLParser.readCameraSettings(xenv);

            Scientrace.MaterialProperties env_material = Scientrace.MaterialProperties.FromIdentifier(environment_material_id);
            retenv = new Scientrace.Object3dEnvironment(env_material, env_radius);
            retenv.perishAtBorder = true;
            retenv.tag            = this.X.getXStringByName(xenv, "Tag", "ScientraceXML_Setup");

            //Parsing lightsources
            this.lp = new XMLLightSourceParser(retenv);
            this.lp.parseLightsources(xenv, retenv);

            //ADDING UNDERLYING BODIES/OBJECTS
            this.parseXObject3dCollectionContent(xenv, retenv);

            //return environment
            return(retenv);
        }
        public List <PlaneBorder> borders; // = new List<PlaneBorder>();

        public PlaneBorderEnclosedVolume(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops, List <PlaneBorder> enclosing_borders) : base(parent, mprops)
        {
            List <PlaneBorder> effective_borders = new List <PlaneBorder>();

            for (int index1 = 0; index1 < enclosing_borders.Count; index1++)
            {
                bool this_one_is_OK = true;
                for (int index2 = index1 + 1; index2 < enclosing_borders.Count; index2++)
                {
                    this_one_is_OK = this_one_is_OK && (!enclosing_borders[index1].overlapsWithPlane(enclosing_borders[index2]));
                }                 //end index2 loop
                if (this_one_is_OK)
                {
                    effective_borders.Add(enclosing_borders[index1]);
                }
                else
                {
                    //Console.WriteLine("WARNING: DISPOSED DUPLICATE BORDER:"+enclosing_borders[index1]);
                }         //end this_one_is_OK
            }             //end index1 loop
            if (effective_borders.Count != enclosing_borders.Count)
            {
                Console.WriteLine(effective_borders.Count.ToString() + " out of " + enclosing_borders.Count + " non-duplicate borders preserved (" + (enclosing_borders.Count - effective_borders.Count) + " duplicates disposed)");
            }
            this.borders = effective_borders;
        }
Beispiel #6
0
 public Sphere(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops,
               Scientrace.Location aLocation, double sphereRadius
               ) : base(parent, mprops)
 {
     this.loc    = aLocation;
     this.radius = sphereRadius;
 }
Beispiel #7
0
 // Constructor: plane, sphereCenterLoc, sphereRadius
 protected DoubleConvexLens(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops,
                            //Scientrace.PlaneBorder lensPlane,
                            Scientrace.Location sphere1CenterLoc, double sphere1Radius,
                            Scientrace.Location sphere2CenterLoc, double sphere2Radius)
     : base(parent, mprops)
 {
     this.paramInit(sphere1CenterLoc, sphere1Radius, sphere2CenterLoc, sphere2Radius);
 }
 public ShadowObject3d(ShadowObject3d copyObject)
 {
     this.parent        = copyObject.parent;
     this.materialprops = copyObject.materialprops;
     this.class_type    = copyObject.class_type;
     this.factory_id    = copyObject.factory_id;
     this.arguments     = new Dictionary <string, object>(copyObject.arguments);
 }
Beispiel #9
0
 public PhysicalObject3d(Object3dCollection parent, Scientrace.MaterialProperties materialproperties) : base(parent, materialproperties)
 {
     this.surface_sides = new HashSet <SurfaceSide>()
     {
         Scientrace.SurfaceSide.Both
     };
     //this.surface_sides.Add(Scientrace.SurfaceSide.Both);
     //this.materialproperties = materialproperties;
 }
Beispiel #10
0
 // Constructor: plane, sphereCenterLoc, sphereRadius
 protected PlanoConvexLens(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops,
                           Scientrace.PlaneBorder lensPlane, Scientrace.Location sphereCenterLoc, double sphereRadius)
     : base(parent, mprops)
 {
     this.lensPlane       = lensPlane;
     this.sphereCenterLoc = sphereCenterLoc;
     this.sphereRadius    = sphereRadius;
     this.dummySphere     = new Scientrace.Sphere(null, null, sphereCenterLoc, sphereRadius);
 }
        public static Scientrace.ParabolicMirror CreateAtFocus(Scientrace.Object3dCollection parent,
                                                               Scientrace.MaterialProperties mprops, Scientrace.Location focusloc,
                                                               double distancetormirror, Scientrace.UnitVector zaxis,
                                                               AbstractGridBorder cborder)
        {
            double c = 1 / (4 * distancetormirror);

            Scientrace.Location loc = (focusloc - (zaxis.toVector() * distancetormirror)).toLocation();
            return(new Scientrace.ParabolicMirror(parent, mprops, loc, zaxis, c, cborder));
        }
        public FlatSurfaceObject3d(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops) : base(parent, mprops)
        {
            //this.surface_sides = new HashSet<SurfaceSide>() {Scientrace.SurfaceSide.Both, Scientrace.SurfaceSide.Front, Scientrace.SurfaceSide.Back};

            //only front surface by default:
            this.surface_sides = new HashSet <SurfaceSide>()
            {
                Scientrace.SurfaceSide.Front
            };
        }
Beispiel #13
0
 private void setDefaults(Object3dCollection parent, MaterialProperties mp)
 {
     this.tag                = this.GetType().ToString();
     this.parseOrder         = TraceJournal.Instance.rnd.NextDouble();
     this.materialproperties = mp;
     this.parent             = parent;
     if (this.hasParent())
     {
         this.parent.addObject3d(this);
     }
 }
Beispiel #14
0
 public static MaterialProperties FromIdentifier(string identifier)
 {
     if (MaterialProperties.materials.Count < 1)
     {
         MaterialProperties.buildMaterialList();
     }
     Scientrace.MaterialProperties retmat = MaterialProperties.getMaterial(identifier);
     if (retmat == null)
     {
         throw new ArgumentException("MaterialProperties Identifier \"" + identifier + "\" is unknown.");
     }
     return(retmat);
 }
Beispiel #15
0
 public ComplexBorderedVolume(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops, List <List <PlaneBorder> > enclosing_borders) : base(parent, mprops)
 {
     /*foreach (PlaneBorder aBorder in enclosing_borders) {
      *      Console.WriteLine("A border added to PlaneBorderEnclosedVolume: "+aBorder.getNormal().trico()+" @ "+aBorder.getCenterLoc());
      *      }*/
     this.subVolumes = new List <PlaneBorderEnclosedVolume>();
     foreach (List <PlaneBorder> pblist in enclosing_borders)
     {
         PlaneBorderEnclosedVolume pbvol = new PlaneBorderEnclosedVolume(null, mprops, pblist);
         this.subVolumes.Add(pbvol);
         //this.borders = enclosing_borders;
     }
     //Console.WriteLine("Number of subvolumes for {"+this.tag+"}: "+this.subVolumes.Count);
 }
Beispiel #16
0
        // Factory method: lensFlatCenterLoc, sphereRadius, lensDiameter
        static public Scientrace.PlanoConvexLens CreateWithLensDiameter(Scientrace.Object3dCollection parent,
                                                                        Scientrace.MaterialProperties mprops,
                                                                        Scientrace.Location lensFlatCenterLoc, double lensDiameter,
                                                                        Scientrace.NonzeroVector sphereRadiusVec)
        {
            Scientrace.PlaneBorder aPlane = new PlaneBorder(lensFlatCenterLoc, sphereRadiusVec);
            double r /*sphere radius*/    = sphereRadiusVec.length;
            double x /*lens radius*/      = lensDiameter / 2;
            double y /*distance lens center to sphere center*/ = Math.Sqrt((r * r) - (x * x));
            double t /*thickness*/ = r - y;

            //Console.WriteLine("sphereradius: "+r+" lens thickness: "+t+" y:"+y+" x:"+x);

            if (t <= 0)
            {
                throw new Exception("This PlanoConvexLens cannot be created: " + sphereRadiusVec.trico() + "/" + lensDiameter);
            }
            Scientrace.Location sphereLoc = lensFlatCenterLoc - (sphereRadiusVec.normalizedVector() * y);
            //Console.WriteLine("sphereLoc: "+sphereLoc.trico()+" lensFlatCenterLoc: "+t+" lensFlatCenterLoc:"+lensFlatCenterLoc.trico());
            return(new PlanoConvexLens(parent, mprops, aPlane, sphereLoc, r));
        }
        /// <summary>
        /// The parabolic mirror is one of the key elements of the SunCycle concentrator
        /// When light is directed onto a parabolic mirror in the right direction the
        /// lightrays will reflect towards a single point, hence it can be used as a concentrator.
        /// </summary>
        /// <param name="parent">
        /// A <see cref="Scientrace.Object3dCollection"/> in which the physicalobject "parabolicmirror" is placed.
        /// </param>
        /// <param name="mprops">
        /// A <see cref="Scientrace.MaterialProperties"/> instance defines the properties of the mirror.
        /// </param>
        /// <param name="loc">
        /// A <see cref="Scientrace.Location"/> defines the location which has to be shifted to 0,0,0 to make z = x^2 + y^2 = 0
        /// </param>
        /// <param name="zaxis">
        /// A <see cref="Scientrace.UnitVector"/> pointing the direction of the norm at the "bottom" of the mirror pointing "up"
        /// </param>
        /// <param name="c">
        /// A <see cref="System.Double"/>, the value c for which z = c(x^2+y^2) after a location shift.
        /// </param>
        /// <param name="cborder">
        /// A <see cref="CylindricalBorder"/> the mirror only exists between these borders.
        /// </param>
        public ParabolicMirror(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops,
                               Scientrace.Location loc, Scientrace.UnitVector zaxis, double c,
                               AbstractGridBorder cborder) : base(parent, mprops)
        {
            /* Console.WriteLine("Mirror props: loc:"+
             *                        loc.trico()+" zax:"+zaxis.trico()+ " c:"+c +" border: "+cborder.ToString()); */
            this.c       = c;
            this.loc     = loc;
            this.zaxis   = zaxis;
            this.cborder = cborder;


            Scientrace.UnitVector basevec1 = new Scientrace.UnitVector(1, 0, 0);
            if (Math.Abs(zaxis.dotProduct(basevec1)) > 0.8)
            {
                basevec1 = new Scientrace.UnitVector(0, 1, 0);
            }
            Scientrace.UnitVector v = basevec1.crossProduct(zaxis).tryToUnitVector();
            trf = new VectorTransformOrthonormal(zaxis, v, VectorTransform.SWAP_U_WITH_W);

            //Console.WriteLine("V transform: "+trf.transform(v).trico()+ " z: "+zaxis+" transform(Z):"+trf.transform(zaxis).trico());
        }
        public static PlaneBorderEnclosedVolume createTruncatedPyramid(
            Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops,
            List <Scientrace.Location> front_corners, Scientrace.Location pyramid_top_location, PlaneBorder topping_plane)
        {
            /*// DEBUG INFO:
             * Console.WriteLine("DEBUG: creating topped pyramid with front_corners: ");
             * foreach (Scientrace.Location aLoc in front_corners) {
             *      Console.Write("Location: "+aLoc.trico());
             *      }
             * Console.WriteLine("Top location: "+pyramid_top_location.trico());
             * Console.WriteLine("topping_plane: "+topping_plane);
             * // END DEBUG INFO */
            if (front_corners.Count < 3)
            {
                throw new IndexOutOfRangeException("(topped) pyramid must have -at least- 3 front_corners in list (=" + front_corners.Count + ").");
            }
            List <Scientrace.PlaneBorder> truncatedPyramidBorders = new List <Scientrace.PlaneBorder>();

            truncatedPyramidBorders.Add(     //adding large (opening) plane
                PlaneBorder.createBetween3LocationsPointingTo(front_corners[0], front_corners[1], front_corners[2], pyramid_top_location)
                );

            int fcc = front_corners.Count;

            for (int iBorder = 0; iBorder < fcc; iBorder++)       //adding side planes
            //Console.WriteLine("PLANE:"+
            //front_corners[iBorder].trico()+ front_corners[(iBorder+1)%fcc].trico()+ pyramid_top_location.trico()+" towards: "+front_corners[(iBorder+2)%fcc]);
            {
                truncatedPyramidBorders.Add(
                    PlaneBorder.createBetween3LocationsPointingTo(
                        front_corners[iBorder], front_corners[(iBorder + 1) % fcc], pyramid_top_location, front_corners[(iBorder + 2) % fcc])
                    );
            }

            truncatedPyramidBorders.Add(topping_plane);     //adding small (closing) plane

            return(new PlaneBorderEnclosedVolume(parent, mprops,
                                                 truncatedPyramidBorders));
        }         // end createTruncatedPyramid Factory Method
Beispiel #19
0
        public Object3dCollection[] division; //firsthalf, secondhalf;
        //public Scientrace.RectangularPrism dummyRect;

        /// <summary>
        /// The CircularFresnelPrism is developed specifically for the SunCycle system but can be used
        /// for different purposes. It generates a filled Object3dCollection with
        /// </summary>
        /// <param name="parent">
        /// A <see cref="Object3d"/>
        /// </param>
        /// <param name="surroundingsproperties">
        /// A <see cref="MaterialProperties"/>
        /// </param>
        /// <param name="loc">
        /// A <see cref="Location"/>
        /// </param>
        /// <param name="surfacev1">
        /// A <see cref="NonzeroVector"/> orthogonal to the prism-teeth "length"-direction.
        /// </param>
        /// <param name="surfacev2">
        /// A <see cref="NonzeroVector"/>
        /// </param>
        /// <param name="surfacev3">
        /// The Z axis </param>
        /// <param name="teethCount">
        /// A int representing the number of teeth over the fresnel surface.
        /// </param>
        /// <param name="fresnelMaterial">
        /// A <see cref="MaterialProperties"/>
        /// </param>

        public CircularFresnelPrism(Object3dCollection parent, MaterialProperties surroundingsproperties,
                                    Location loc, NonzeroVector surfacev1, NonzeroVector surfacev2, NonzeroVector zaxisheight,
                                    double largeAngle_rad, double shortAngle_rad, int teethCount,
                                    MaterialProperties fresnelMaterial)
            : base(parent, surroundingsproperties)
        {
            //check vectors
            try{ surfacev1.toUnitVector(); }
            catch { throw new ZeroNonzeroVectorException("Fresnel Prism surface 1 has length 0"); }
            try{ surfacev2.toUnitVector(); }
            catch { throw new ZeroNonzeroVectorException("Fresnel Prism surface 2 has length 0"); }
            try{ zaxisheight.toUnitVector(); }
            catch { throw new ZeroNonzeroVectorException("Z-axis height has length 0"); }

            //set attributes
            this.loc       = loc;
            this.surfacev1 = surfacev1;
            this.surfacev2 = surfacev2;
            this.surfacev3 = zaxisheight;

            this.largeAngle      = largeAngle_rad;
            this.relative_angle  = Math.PI - (shortAngle_rad + largeAngle_rad);
            this.teethCount      = teethCount;
            this.fresnelMaterial = fresnelMaterial;

            //create "divisions" that organises the Fresnel-zones in segments in order to boost performance.
            this.division = new Object3dCollection[this.divisioncount];
            for (int idiv = 0; idiv < this.divisioncount; idiv++)
            {
                this.division[idiv] = new Object3dCollection(this, surroundingsproperties);
                this.division[idiv].virtualCollection = true;
                this.division[idiv].tag = "fresnel_div_" + idiv;
            }

            this.addElements();
            this.dummyborder = new RectangularPrism(null, this.materialproperties, loc - (surfacev1 + surfacev2),
                                                    surfacev1 * 2, surfacev2 * 2, surfacev3.normalized() * this.total_prism_height);
        }
Beispiel #20
0
 public override double enterAbsorption(Trace trace, Scientrace.UnitVector norm, Scientrace.MaterialProperties previousMaterial)
 {
     return(1);
 }
Beispiel #21
0
 public Cube(Object3dCollection parent, Scientrace.MaterialProperties mprops, int x, int y, int z, int width, int length, int height) : base(parent, mprops)
 {
     //TODO create constructor and basic behaviour
 }
Beispiel #22
0
        //length is inherited from Scientrace.Prism

/* although it has no physical significance w,l and h can be thought of as below.
 *       ____
 *      /   /|
 * /__ / |
 |   | |
 | h|   | /
 |___|/ l
 |   w
 */

        public Cube(Object3dCollection parent, Scientrace.MaterialProperties mprops) : base(parent, mprops)
        {
        }
 public EnclosedVolume(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops) : base(parent, mprops)
 {
     this.hasVolume = true;
 }
Beispiel #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Scientrace.Rectangle"/> class on a
 /// given location with a given width and height vector. The "pointingto" vector,
 /// which defines the front of the cell, is defined by the crossproduct u * v.
 /// </summary>
 /// <param name='parent'>
 /// What collection is this object part of?
 /// </param>
 /// <param name='mprops'>
 /// Materialproperties
 /// </param>
 /// <param name='loc'>
 /// The location of the rectangle.
 /// </param>
 /// <param name='u'>
 /// Width?
 /// </param>
 /// <param name='v'>
 /// Height?
 /// </param>
 public Rectangle(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops,
                  Scientrace.Location loc, Scientrace.NonzeroVector u, Scientrace.NonzeroVector v) : base(parent, mprops)
 {
     this.init_Loc_width_height(loc, u, v);
 }
Beispiel #25
0
 public ShadowObject3d(ShadowObject3d copyObject)
 {
     this.parent = copyObject.parent;
     this.materialprops = copyObject.materialprops;
     this.class_type = copyObject.class_type;
     this.factory_id = copyObject.factory_id;
     this.arguments = new Dictionary<string, object>(copyObject.arguments);
 }
Beispiel #26
0
 public ShadowObject3d(Type object3dType, Scientrace.Object3dCollection parent, Scientrace.MaterialProperties materialprops)
 {
     this.parent        = parent;
     this.materialprops = materialprops;
     this.class_type    = object3dType;
 }
Beispiel #27
0
 //length inherited from Prism
 public TriangularPrism(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops,
                        Scientrace.Location loc, Scientrace.NonzeroVector width, Scientrace.NonzeroVector height,
                        Scientrace.NonzeroVector length) : base(parent, mprops)
 {
     this.paramInit(loc, width, height, length);
 }
 public override double enterReflection(Trace trace, Scientrace.UnitVector norm, Scientrace.MaterialProperties previousMaterial)
 {
     //Console.WriteLine("New: "+this.reflection_fraction);
     return(this.reflection_fraction);
 }
Beispiel #29
0
 public ShadowObject3d(Type object3dType, Scientrace.Object3dCollection parent, Scientrace.MaterialProperties materialprops)
 {
     this.parent = parent;
     this.materialprops = materialprops;
     this.class_type = object3dType;
 }
Beispiel #30
0
 private void setDefaults(Object3dCollection parent, MaterialProperties mp)
 {
     this.tag = this.GetType().ToString();
     this.parseOrder = TraceJournal.Instance.rnd.NextDouble();
     this.materialproperties = mp;
     this.parent = parent;
     if (this.hasParent())
     this.parent.addObject3d(this);
 }
Beispiel #31
0
 public Rectangle(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops,
                  Scientrace.Location cellcenterloc, Scientrace.Location pointingto, Scientrace.UnitVector orthogonaldirection,
                  double sidelength) : base(parent, mprops)
 {
     this.init_Center_and_Sidelength(cellcenterloc, pointingto, orthogonaldirection, sidelength);
 }