Exemple #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();
        }
 public Scientrace.Location transformback(Scientrace.Location loc)
 {
     return(this.transformback(loc.toVector()).toLocation());
 }