Example #1
0
        protected void init_Center_and_Sidelength(Scientrace.Location cellcenterloc, Scientrace.Location pointingto, Scientrace.UnitVector orthogonaldirection,
                                                  double sidelength)
        {
            //Check whether cellcenterloc and pointingto values are different
            if (cellcenterloc.distanceTo(pointingto) == 0)
            {
                throw new ZeroNonzeroVectorException("The location (" + cellcenterloc.ToCompactString() + ") of a Rectangle instance may not be equal to the direction (" + pointingto.ToCompactString() + ") it is pointed towards");
            }

            NonzeroVector cellu, cellv, cellc;

            //define top-cell vector orthogonal to orthogonaldirection and the vectorpoint.
            Scientrace.UnitVector focusdir = (pointingto.toVector() - cellcenterloc.toVector()).tryToUnitVector();
            //Console.WriteLine("POINTINGTO: "+pointingto.trico()+ " focusdir: "+focusdir.trico());
            this.front_normal_direction = focusdir.copy();
            cellu = orthogonaldirection.crossProduct(focusdir).tryToNonzeroVector();
            cellu.normalize();
            //UPDATE 20151102: added "negative" to conserve surface direction after crossproduct operation.
            cellv = cellu.crossProduct(focusdir.negative()).tryToNonzeroVector();
            cellv.normalize();
            cellu = cellu * sidelength;     //surface of cell eq: sidelength * sidelength
            cellv = cellv * sidelength;
            cellc = (cellu + cellv) * 0.5;

            this.parallelogram = new Scientrace.Parallelogram(cellcenterloc - cellc.toLocation(), cellu, cellv);
            this.preserveSVGRatio();
            this.addSurfaceMarkers();
        }
Example #2
0
 public void init(Scientrace.Location startloc, Scientrace.Location endloc)
 {
     if (startloc.distanceTo(endloc) <= 0)
     {
         throw new ArgumentOutOfRangeException("ERROR: Startloc (" + startloc.ToString() + ") and endloc (" + endloc.ToString() + ") are equal for linepiece, no line nor direction possible");
     }
     this.startingpoint = startloc;
     this.endingpoint   = endloc;
     this.calculateDirection();
 }
Example #3
0
 public void TestDistance()
 {
     Scientrace.Location loc1 = new Scientrace.Location(1, 1, 1);
     Scientrace.Location loc2 = new Scientrace.Location(4, 5, 6);
     Assert.AreEqual(loc1.distanceTo(loc2), Math.Sqrt(50));
 }
Example #4
0
 public double distanceFromSphereCenterToPlano()
 {
     Scientrace.Location h1 = this.planoCenterLoc();
     return(h1.distanceTo(this.sphereCenterLoc));
 }
Example #5
0
        /* end of interface IBorder3D implementation */

        public bool contains(Scientrace.Location aLocation, double margin)
        {
            return((aLocation.distanceTo(this.loc) < Math.Abs(this.radius + margin))
                   == this.isPositive());
        }
Example #6
0
 public void TestDistance()
 {
     Scientrace.Location loc1 = new Scientrace.Location(1, 1, 1);
     Scientrace.Location loc2 = new Scientrace.Location(4, 5, 6);
     Assert.AreEqual(loc1.distanceTo(loc2), Math.Sqrt(50));
 }