Example #1
0
 //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;
 }
Example #2
0
 public Sphere(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops,
               Scientrace.Location aLocation, double sphereRadius
               ) : base(parent, mprops)
 {
     this.loc    = aLocation;
     this.radius = sphereRadius;
 }
 //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;
 }
        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;
        }
Example #6
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);
 }
Example #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);
 }
Example #8
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
            };
        }
Example #11
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);
 }
Example #12
0
        public void parseXObject3dCollectionContent(XElement xcol, Scientrace.Object3dCollection objectcollection)
        {
            if (xcol == null)
            {
                return;
            }
            XMLObject3dParser    o3dp = new XMLObject3dParser(objectcollection);
            ShadowClassConstruct shadowConstructor = new ShadowClassConstruct(objectcollection);

            //PARSE OBJECTS WITHIN COLLECTION HERE
            foreach (XElement xel in xcol.Elements())
            {
                this.parseXObject3d(xel, objectcollection, o3dp, shadowConstructor);
            }
        }
Example #13
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));
        }
Example #14
0
        /// <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
Example #16
0
	public Prism(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops):base(parent, mprops) {
		}
Example #17
0
 public EnclosedVolume(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops) : base(parent, mprops)
 {
     this.hasVolume = true;
 }
Example #18
0
        public void parseXObject3d(XElement xel, Scientrace.Object3dCollection col, XMLObject3dParser o3dp, ShadowClassConstruct shadowConstructor)
        {
            Scientrace.Object3d createdObject3d = null;
            switch (xel.Name.ToString())
            {
            case "CircularFresnelPrism":
                createdObject3d = o3dp.parseXFresnelPrism(xel);
                break;

            case "ParabolicMirror":
                createdObject3d = o3dp.parseXParabolicMirror(xel);
                //PARSE PARAB MIRROR
                break;

            case "Prism":             //fall through
            case "TriangularPrism":
                createdObject3d = shadowConstructor.constructTriangularPrism(xel);
                //createdObject3d = o3dp.parseXTriangularPrism(xel);
                break;

            case "RectangularPrism":
                createdObject3d = o3dp.parseXRectangularPrism(xel);
                break;

            case "SquareCell":
            case "Rectangle":
                //square cell can be used for any square or rectangular surface-object
                //createdObject3d = o3dp.parseXRectangle(xel);
                createdObject3d = shadowConstructor.constructRectangle(xel);
                break;

            case "Sphere":
                createdObject3d = o3dp.parseXSphere(xel);
                break;

            case "FresnelLens":
                createdObject3d = shadowConstructor.constructFresnelLens(xel);
                break;

            case "FresnelLensRing":
                createdObject3d = shadowConstructor.constructFresnelLensRing(xel);
                break;

            case "PlanoConvexLens":
                createdObject3d = o3dp.parseXPlanoConvexLens(xel);
                break;

            case "DoubleConvexLens":
                //createdObject3d = o3dp.parseXDoubleConvexLens(xel);
                createdObject3d = shadowConstructor.constructDoubleConvexLens(xel);
                break;

            case "BorderedVolume":
                createdObject3d = o3dp.parsXBorderedVolume(xel);
                break;

            case "ToppedPyramid":
            case "TruncatedPyramid":
                createdObject3d = o3dp.parseXTruncatedPyramid(xel);
                break;

            case "CameraViewpoint":        //fallthrough
            case "CameraFrom":             //fallthrough
            case "CameraRotation":
                //Cam settings set at environment.
                break;

            case "LightSource":
                //do nothing, already parsed previously
                break;

            case "Ignore":
            case "IGNORE":
                //do nothing, IGNORE!
                break;

            default:
                if (!(xel.Name.ToString().Substring(0, 3) == "REM"))
                {
                    Console.WriteLine("WARNING: UNKNOWN OBJECT: " + xel.Name + " \n[XML code]\n" + xel.ToString() + "\n[/XML code]\n");
                }
                break;
            }
            if (createdObject3d != null)
            {
                XMLTraceModifierParser xtmp = new XMLTraceModifierParser();
                List <Scientrace.UniformTraceModifier> utms = xtmp.getModifiers(xel);
                createdObject3d.addSurfaceModifiers(utms);
            }
        }         // end parseXObject3d
Example #19
0
 public ShadowClassConstruct(Scientrace.Object3dCollection parent) : base()
 {
     this.parentcollection = parent;
 }
Example #20
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);
 }
Example #21
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);
 }
Example #22
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);
 }
Example #23
0
 public ShadowObject3d(Type object3dType, Scientrace.Object3dCollection parent, Scientrace.MaterialProperties materialprops)
 {
     this.parent        = parent;
     this.materialprops = materialprops;
     this.class_type    = object3dType;
 }
Example #24
0
 public ShadowObject3d(Type object3dType, Scientrace.Object3dCollection parent, Scientrace.MaterialProperties materialprops)
 {
     this.parent = parent;
     this.materialprops = materialprops;
     this.class_type = object3dType;
 }
Example #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);
 }