Ejemplo n.º 1
0
        /// <summary>
        /// Creates a line starting at the projection of this.loc on the intersection between this and another Plane.
        /// The direction of the line is that of the crossproduct of this.normal and anotherPlane.normal.
        /// </summary>
        /// <returns>A line along the intersection of this and anotherPlane, returns "null" if two planes are significantly parallel</returns>
        /// <param name="anotherPlane">A plane to calculate the intersection with</param>
        public Scientrace.Line getIntersectionLineWith(Scientrace.Plane anotherPlane)
        {
            Scientrace.UnitVector n1, n2;
            n1 = this.getNorm();
            n2 = anotherPlane.getNorm();
            Vector tw = n1.crossProduct(n2);

            if (tw.length < MainClass.SIGNIFICANTLY_SMALL)
            {
                //Console.WriteLine("WARNING: two planes do not intersect since they are parallel.");
                return(null);
            }
            UnitVector intersection_direction = tw.tryToUnitVector();

            Vector tl1 = n1.crossProduct(intersection_direction);

            if (tl1.length == 0)
            {
                throw new Exception("Plane.getIntersectionLineWith/l1.length can never be zero. If this happens, notify the [email protected] about this..." + this.ToString() + anotherPlane.ToString());
            }
            // l1 lies in "this" plane, and is orthogonal to the intersectionline-direction
            UnitVector l1 = tl1.tryToUnitVector();

            // where l1, starting at this.loc, meets anotherPlane we found a location on the intersectionline.
            Scientrace.Location retLoc = anotherPlane.lineThroughPlane(new Line(this.loc, l1));
            if (retLoc == null)
            {
                Console.WriteLine("WARNING: retLoc == null; l1: " + l1.ToString() + " ; anotherPlane:" + anotherPlane.getNorm().ToString());
                return(null);
            }
            return(new Line(retLoc, intersection_direction));
        }
Ejemplo n.º 2
0
        public Line reflectLine(Scientrace.Line line, Scientrace.Plane plane)
        {
            Scientrace.UnitVector norm = plane.getNorm();

            /*ADDED and removed 20131030 make surface normal in direction of incoming beam
             * if (line.direction.dotProduct(norm) > 0) {
             *      norm.negated();
             *      }*/
            return(this.reflectLineAbout(line, norm));
        }
Ejemplo n.º 3
0
        /* LINEAR MODIFIER METHODS >>> */

        public Scientrace.Plane linearModify(Scientrace.Plane aPlane)
        {
            Scientrace.NonzeroVector aSurfaceNormal = aPlane.getNorm();
            Scientrace.NonzeroVector newNormal      =
                this.modify(aSurfaceNormal,
                            this.random_modification_select ? this.getRandomNodeNumber() : this.getNextNodeNumber(),
                            this.modify_traces_count);
            return(Scientrace.Plane.newPlaneOrthogonalTo(aPlane.loc,
                                                         newNormal, aPlane.u, aPlane.v));
        }