Exemplo n.º 1
0
 // Copy constructor
 public IntersectionPoint(IntersectionPoint copyIntersectionPoint)
 {
     this.loc =
     (copyIntersectionPoint.loc == null) ?
     null : new Location(copyIntersectionPoint.loc);
     this.flatshape = copyIntersectionPoint.flatshape;
     /* this.flatshape =
     (copyIntersectionPoint.flatshape == null) ?
     null : new FlatShape2d(copyIntersectionPoint.flatshape); */
 }
Exemplo n.º 2
0
        // Copy constructor
        public IntersectionPoint(IntersectionPoint copyIntersectionPoint)
        {
            this.loc =
                (copyIntersectionPoint.loc == null) ?
                null : new Location(copyIntersectionPoint.loc);
            this.flatshape = copyIntersectionPoint.flatshape;

            /* this.flatshape =
             *      (copyIntersectionPoint.flatshape == null) ?
             *      null : new FlatShape2d(copyIntersectionPoint.flatshape); */
        }
Exemplo n.º 3
0
        public IntersectionPoint[] intersects11circleborder(Trace trace)
        {
            Scientrace.Line line = trace.traceline;
            double          d1, d2, dx, dy, lx, ly;
            double          ABCa, ABCb, ABCc, discr;

            Scientrace.Vector              v1, v2;
            Scientrace.FlatShape2d         plane1, plane2;
            Scientrace.IntersectionPoint[] ip;
            dx = line.direction.x;
            dy = line.direction.y;
            lx = line.startingpoint.x;
            ly = line.startingpoint.y;

            ABCa  = Math.Pow(ly, 2) + Math.Pow(lx, 2);
            ABCb  = 2 * ((ly * dy) + (lx * dx));
            ABCc  = Math.Pow(dy, 2) + Math.Pow(dx, 2) - 1;
            discr = Math.Pow(ABCb, 2) - (4 * ABCa * ABCc);
            if (discr < 0)
            {
                ip = new Scientrace.IntersectionPoint[0];
                //ip[0] = null;
                //ip[1] = null;
                return(ip);
            }
            if (discr == 0)
            {
                ip = new Scientrace.IntersectionPoint[1];
                d1 = ((-ABCb) + Math.Sqrt(Math.Pow(ABCb, 2) - (4 * ABCa * ABCc))) / (2 * ABCa);
                v1 = (line.direction.toVector() * d1) + line.startingpoint.toVector();
                //plane1 is based on v1 rotated 90 degrees which makes: x' = -y, y' = x, z = z
                plane1 = new Scientrace.FlatShape2d(v1.toLocation(), new Scientrace.UnitVector(0, 0, 1),
                                                    new Scientrace.UnitVector(-v1.y, v1.x, v1.z));
                ip[0] = new IntersectionPoint(v1.toLocation(), plane1);
                return(ip);
            }
            d1     = ((-ABCb) + Math.Sqrt(Math.Pow(ABCb, 2) - (4 * ABCa * ABCc))) / (2 * ABCa);
            d2     = ((-ABCb) - Math.Sqrt(Math.Pow(ABCb, 2) - (4 * ABCa * ABCc))) / (2 * ABCa);
            v1     = (line.direction.toVector() * d1) + line.startingpoint.toVector();
            v2     = (line.direction.toVector() * d2) + line.startingpoint.toVector();
            ip     = new Scientrace.IntersectionPoint[2];
            plane1 = new Scientrace.FlatShape2d(v1.toLocation(), new Scientrace.UnitVector(0, 0, 1),
                                                new Scientrace.UnitVector(-v1.y, v1.x, v1.z));
            ip[0]  = new IntersectionPoint(v1.toLocation(), plane1);
            plane2 = new Scientrace.FlatShape2d(v2.toLocation(), new Scientrace.UnitVector(0, 0, 1),
                                                new Scientrace.UnitVector(-v2.y, v2.x, v2.z));
            ip[1] = new IntersectionPoint(v2.toLocation(), plane2);
            return(ip);
        }
Exemplo n.º 4
0
 public Intersection(bool intersects, Scientrace.Object3d object3d, Scientrace.Location enterloc,
                     Scientrace.FlatShape2d enterplane, Scientrace.Location exitloc)
 {
     //same as constructor above but with leaving = false.
     this.intersects = intersects;
     this.object3d   = object3d;
     this.enter      = new IntersectionPoint(enterloc, enterplane);
     if (exitloc == null)
     {
         this.exit = null;
     }
     else
     {
         this.exit = new IntersectionPoint(exitloc, null);
     }
     this.leaving = false;
     this.checkObject();    //<- DEBUGGING:
 }
Exemplo n.º 5
0
 public Intersection(bool intersects, Scientrace.Object3d object3d, Scientrace.Location enterloc,
                     Scientrace.FlatShape2d enterplane, Scientrace.Location exitloc, bool leaving)
 {
     this.intersects = intersects;
     this.object3d   = object3d;
     this.enter      = new IntersectionPoint(enterloc, enterplane);
     //plane of exitloc irrelevant
     if (exitloc == null)
     {
         this.exit = null;
     }
     else
     {
         this.exit = new IntersectionPoint(exitloc, null);
     }
     this.leaving = leaving;
     this.checkObject();    //<- DEBUGGING:
 }
Exemplo n.º 6
0
 public Scientrace.FlatShape2d setBack()
 {
     this.back_flatshape = new Scientrace.Triangle(this.loc+this.length.toLocation(), this.height, this.width);
     this.back_flatshape.surfaceproperties = SurfaceProperties.NewSurfaceModifiedObject(this, this.back_surface_modifiers);
     return this.back_flatshape;
 }
Exemplo n.º 7
0
        public IntersectionPoint[] intersects11circleborder(Trace trace)
        {
            Scientrace.Line line = trace.traceline;
            double d1, d2, dx, dy, lx, ly;
            double ABCa, ABCb, ABCc, discr;
            Scientrace.Vector v1, v2;
            Scientrace.FlatShape2d plane1, plane2;
            Scientrace.IntersectionPoint[] ip;
            dx = line.direction.x;
            dy = line.direction.y;
            lx = line.startingpoint.x;
            ly = line.startingpoint.y;

            ABCa = Math.Pow(ly,2)+Math.Pow(lx,2);
            ABCb = 2*((ly*dy) + (lx*dx));
            ABCc = Math.Pow(dy,2)+Math.Pow(dx,2)-1;
            discr = Math.Pow(ABCb, 2)-(4*ABCa*ABCc);
            if (discr < 0) {
            ip = new Scientrace.IntersectionPoint[0];
            //ip[0] = null;
            //ip[1] = null;
            return ip;
            }
            if (discr == 0) {
            ip = new Scientrace.IntersectionPoint[1];
            d1 = ((-ABCb)+Math.Sqrt(Math.Pow(ABCb, 2)-(4*ABCa*ABCc)))/(2*ABCa);
            v1 = (line.direction.toVector()*d1)+line.startingpoint.toVector();
                //plane1 is based on v1 rotated 90 degrees which makes: x' = -y, y' = x, z = z
            plane1 = new Scientrace.FlatShape2d(v1.toLocation(), new Scientrace.UnitVector(0,0,1),
                                                               new Scientrace.UnitVector(-v1.y, v1.x, v1.z));
            ip[0] = new IntersectionPoint(v1.toLocation(), plane1);
            return ip;
            }
            d1 = ((-ABCb)+Math.Sqrt(Math.Pow(ABCb, 2)-(4*ABCa*ABCc)))/(2*ABCa);
            d2 = ((-ABCb)-Math.Sqrt(Math.Pow(ABCb, 2)-(4*ABCa*ABCc)))/(2*ABCa);
            v1 = (line.direction.toVector()*d1)+line.startingpoint.toVector();
            v2 = (line.direction.toVector()*d2)+line.startingpoint.toVector();
            ip = new Scientrace.IntersectionPoint[2];
            plane1 = new Scientrace.FlatShape2d(v1.toLocation(), new Scientrace.UnitVector(0,0,1),
                                                               new Scientrace.UnitVector(-v1.y, v1.x, v1.z));
            ip[0] = new IntersectionPoint(v1.toLocation(), plane1);
            plane2 = new Scientrace.FlatShape2d(v2.toLocation(), new Scientrace.UnitVector(0,0,1),
                                                               new Scientrace.UnitVector(-v2.y, v2.x, v2.z));
            ip[1] = new IntersectionPoint(v2.toLocation(), plane2);
            return ip;
        }
Exemplo n.º 8
0
 public Scientrace.FlatShape2d setSide()
 {
     this.side_flatshape = new Scientrace.Parallelogram(this.loc, this.height, this.length);
     this.side_flatshape.surfaceproperties = SurfaceProperties.NewSurfaceModifiedObject(this, this.side_surface_modifiers);
     return(this.side_flatshape);
 }
Exemplo n.º 9
0
 public Scientrace.FlatShape2d setHypothenuse()
 {
     this.hypothenuse_flatshape = new Scientrace.Parallelogram(this.loc+this.width.toLocation(), (this.height-this.width), this.length);
     this.hypothenuse_flatshape.surfaceproperties = SurfaceProperties.NewSurfaceModifiedObject(this, this.hypotenuse_surface_modifiers);
     return this.hypothenuse_flatshape;
 }
Exemplo n.º 10
0
 public IntersectionPoint(Scientrace.Location loc, Scientrace.FlatShape2d flatshape)
 {
     this.loc       = loc;
     this.flatshape = flatshape;
 }
Exemplo n.º 11
0
        public Scientrace.Intersection intersectplanesforobject(Scientrace.Object3d anObject,
                                                                List <Scientrace.FlatShape2d> pgrams)
        {
            Scientrace.Trace       trace      = this;
            Scientrace.Location    firstloc   = null;
            Scientrace.FlatShape2d enterplane = null;
            Scientrace.Location    lastloc    = null;
            double?firstdistance = null;
            double?lastdistance  = null;

            Scientrace.Location tloc;
            double tdistance;

            foreach (Scientrace.FlatShape2d pgram in pgrams)
            {
                tloc = pgram.atPath(trace.traceline);
                if (tloc == null)
                {
                    continue;
                }
                if (((tloc - trace.traceline.startingpoint).dotProduct(trace.traceline.direction)) < trace.getMinDistinctionLength())
                {
                    continue;             //the location (even if increased with one wavelength) is "behind" the trace
                }
                tdistance = tloc.distanceTo(trace.traceline.startingpoint);
                if (firstdistance == null)
                {
                    //assign first and last to first item in collection
                    firstdistance = tdistance;
                    firstloc      = tloc;
                    enterplane    = pgram;
                    lastdistance  = tdistance;
                    lastloc       = tloc;
                }
                if (tdistance < firstdistance)
                {
                    //Console.WriteLine(tdistance.ToString()+"<"+firstdistance.ToString());
                    firstdistance = tdistance;
                    firstloc      = tloc;
                    enterplane    = pgram;
                }
                if (tdistance > lastdistance)
                {
                    //Console.WriteLine("We have a large distance gentlemen");
                    lastdistance = tdistance;
                    lastloc      = tloc;
                }
            }             //end of pgrams-for-loop
            if (firstdistance == null)
            {
                //when no side of the paralellogram has been intersected
                return(new Scientrace.Intersection(false, anObject));
            }
            if (firstdistance == lastdistance)
            {
                lastdistance = null; lastloc = null;
            }
            if (lastdistance == null)
            {
                //Console.WriteLine("I have no ending");
            }
            else
            {
                //Console.WriteLine("I from "+trace.currentObject.GetType()+" @ "+trace.traceline.startingpoint.trico()+" pass through an object");
            }
            Scientrace.Intersection intrs = new Scientrace.Intersection(true, anObject, firstloc, enterplane, lastloc);
            intrs.leaving = (lastloc == null);
            return(intrs);
        }
Exemplo n.º 12
0
 public Scientrace.FlatShape2d setBack()
 {
     this.back_flatshape = new Scientrace.Triangle(this.loc + this.length.toLocation(), this.height, this.width);
     this.back_flatshape.surfaceproperties = SurfaceProperties.NewSurfaceModifiedObject(this, this.back_surface_modifiers);
     return(this.back_flatshape);
 }
Exemplo n.º 13
0
 public Scientrace.FlatShape2d setFront()
 {
     this.front_flatshape = new Scientrace.Triangle(this.loc, this.height, this.width);
     this.front_flatshape.surfaceproperties = SurfaceProperties.NewSurfaceModifiedObject(this, this.front_surface_modifiers);
     return(this.front_flatshape);
 }
Exemplo n.º 14
0
 public Scientrace.FlatShape2d setHypothenuse()
 {
     this.hypothenuse_flatshape = new Scientrace.Parallelogram(this.loc + this.width.toLocation(), (this.height - this.width), this.length);
     this.hypothenuse_flatshape.surfaceproperties = SurfaceProperties.NewSurfaceModifiedObject(this, this.hypotenuse_surface_modifiers);
     return(this.hypothenuse_flatshape);
 }
Exemplo n.º 15
0
 /* LAZY-INITIALIZERS FOR SURFACES */
 public Scientrace.FlatShape2d setBottom()
 {
     this.bottom_flatshape = new Scientrace.Parallelogram(this.loc, this.width, this.length);
     this.bottom_flatshape.surfaceproperties = SurfaceProperties.NewSurfaceModifiedObject(this, this.bottom_surface_modifiers);
     return this.bottom_flatshape;
 }
Exemplo n.º 16
0
 public Scientrace.FlatShape2d setFront()
 {
     this.front_flatshape = new Scientrace.Triangle(this.loc, this.height, this.width);
     this.front_flatshape.surfaceproperties = SurfaceProperties.NewSurfaceModifiedObject(this, this.front_surface_modifiers);
     return this.front_flatshape;
 }
Exemplo n.º 17
0
 public IntersectionPoint(Scientrace.Location loc, Scientrace.FlatShape2d flatshape)
 {
     this.loc = loc;
     this.flatshape = flatshape;
 }
Exemplo n.º 18
0
 public Scientrace.FlatShape2d setSide()
 {
     this.side_flatshape = new Scientrace.Parallelogram(this.loc, this.height, this.length);
     this.side_flatshape.surfaceproperties = SurfaceProperties.NewSurfaceModifiedObject(this, this.side_surface_modifiers);
     return this.side_flatshape;
 }
Exemplo n.º 19
0
 /* LAZY-INITIALIZERS FOR SURFACES */
 public Scientrace.FlatShape2d setBottom()
 {
     this.bottom_flatshape = new Scientrace.Parallelogram(this.loc, this.width, this.length);
     this.bottom_flatshape.surfaceproperties = SurfaceProperties.NewSurfaceModifiedObject(this, this.bottom_surface_modifiers);
     return(this.bottom_flatshape);
 }