コード例 #1
0
        public Location getCrossProduct(Location between)
        {
            Location thisabs = this;
            Location betabs  = between;
            double   x       = thisabs.getY() * betabs.getZ() - thisabs.getZ() * betabs.getY();
            double   y       = thisabs.getZ() * betabs.getX() - thisabs.getX() * betabs.getZ();
            double   z       = thisabs.getX() * betabs.getY() - thisabs.getY() * betabs.getX();

            //thisabs.Dispose();
            //betabs.Dispose();
            return(new Location(x, y, z));
        }
コード例 #2
0
        public static bool isHitting(BoundingBox box1, BoundingBox box2)
        {
            Location box1RefinedMin = box1.getRefinedMinPoint();
            Location box1RefinedMax = box1.getRefinedMaxPoint();
            Location box2RefinedMin = box2.getRefinedMinPoint();
            Location box2RefinedMax = box2.getRefinedMaxPoint();

            Location box1Min = box1RefinedMin.getAbsoluteLocation();
            Location box1Max = box1RefinedMax.getAbsoluteLocation();
            Location box2Min = box2RefinedMin.getAbsoluteLocation();
            Location box2Max = box2RefinedMax.getAbsoluteLocation();

            double myMinX = box1Min.getX();
            double myMinY = box1Min.getY();
            double myMinZ = box1Min.getZ();

            double myMaxX = box1Max.getX();
            double myMaxY = box1Max.getY();
            double myMaxZ = box1Max.getZ();

            double notMinX = box2Min.getX();
            double notMinY = box2Min.getY();
            double notMinZ = box2Min.getZ();

            double notMaxX = box2Max.getX();
            double notMaxY = box2Max.getY();
            double notMaxZ = box2Max.getZ();

            box1RefinedMin.Dispose();
            box1RefinedMax.Dispose();
            box2RefinedMin.Dispose();
            box2RefinedMax.Dispose();

            box1Min.Dispose();
            box1Max.Dispose();
            box2Min.Dispose();
            box2Max.Dispose();

            bool myXInside = (myMinX >= notMinX && myMinX <= notMaxX) || (myMaxX >= notMinX && myMaxX <= notMaxX);
            bool myYInside = (myMinY >= notMinY && myMinY <= notMaxY) || (myMaxY >= notMinY && myMaxY <= notMaxY);
            bool myZinside = (myMinZ >= notMinZ && myMinZ <= notMaxZ) || (myMaxZ >= notMinZ && myMaxZ <= notMaxZ);

            if (myXInside && myYInside && myZinside)
            {
                return(true);
            }

            bool notXInside = (notMinX >= myMinX && notMinX <= myMaxX) || (notMaxX >= myMinX && notMaxX <= myMaxX);
            bool notYInside = (notMinY >= myMinY && notMinY <= myMaxY) || (notMaxY >= myMinY && notMaxY <= myMaxY);
            bool notZInside = (notMinZ >= myMinZ && notMinZ <= myMaxZ) || (notMaxZ >= myMinZ && notMaxZ <= myMaxZ);

            if (notXInside && notYInside && notZInside)
            {
                return(true);
            }
            return(false);
        }
コード例 #3
0
        public Location getRefinedMaxPoint()
        {
            Location max = this.max.clone();

            max.setX(max.getX() * this.getModel().getScaleX());
            max.setY(max.getY() * this.getModel().getScaleY());
            max.setZ(max.getZ() * this.getModel().getScaleZ());
            max.setOwner(this.getModel().getLocation());
            return(max);
        }
コード例 #4
0
        public Location getRefinedMinPoint()
        {
            Location min = this.min.clone();

            min.setX(min.getX() * this.getModel().getScaleX());
            min.setY(min.getY() * this.getModel().getScaleY());
            min.setZ(min.getZ() * this.getModel().getScaleZ());
            min.setOwner(this.getModel().getLocation());
            return(min);
        }
コード例 #5
0
        public Location[] getAbsoluteMinMaxPoints()
        {
            /*
             * This will check children for their min X Y and Z values RELATIVE TO THIS OBJECT
             * THE RETURNED VALUE WILL BE RELATIVE TO THIS OBJECT, EXAMPLE;
             * THIS OBJECT IS AT 14, 14, 14
             * THIS MIN POINT IS -4, -2, -4 (MAKING ITS ABS POSITION AT 10, 12, 10)
             * THE CHILD IS AT 3, 3, 3 OF THIS, MAKING ITS ABS 17, 17, 17
             * THE CHILD MIN POINT IS -6, -6, -6 OF IT, MAKING ITS POSITION RELATIVE TO ITS OBJECT -3, -3, -3
             * THAT MAKES THE RELATAIVE MIN POINT -4, -3, -4 (X FROM THIS MIN, Y FROM CHILD MIN, Z FROM THIS MIN)
             * THAT MAKES THE ABSOLUTE MIN POINT AT 10, 11, 10
             *
             * RETURNS ARRAY TO INCREASE EFFICIENCY, BE SURE TO DISPOSE BOTH
             * getAbsoluteMinMaxPoints()[0] = min_point;
             * getAbsoluteMinMaxPoints()[1] = max_point;
             */
            double minX = (this.min == null ? 0 : this.min.getX());
            double minY = (this.min == null ? 0 : this.min.getY());
            double minZ = (this.min == null ? 0 : this.min.getZ());
            double maxX = (this.max == null ? 0 : this.max.getX());
            double maxY = (this.max == null ? 0 : this.max.getY());
            double maxZ = (this.max == null ? 0 : this.max.getZ());

            foreach (Model child in this.children)
            {
                Location[] minMaxPoints = child.getAbsoluteMinMaxPoints();
                Location   minPoint     = minMaxPoints[0];
                Location   maxPoint     = minMaxPoints[1];
                minPoint.add(child.getLocation());
                maxPoint.add(child.getLocation());
                //COMPARE VALUES
                if (minPoint.getX() < minX)
                {
                    minX = minPoint.getX();
                }
                if (minPoint.getY() < minY)
                {
                    minY = minPoint.getY();
                }
                if (minPoint.getZ() < minZ)
                {
                    minZ = minPoint.getZ();
                }
                //MAX VALUES
                if (maxPoint.getX() > maxX)
                {
                    maxX = maxPoint.getX();
                }
                if (maxPoint.getY() > maxY)
                {
                    maxY = maxPoint.getY();
                }
                if (maxPoint.getZ() > maxZ)
                {
                    maxZ = maxPoint.getZ();
                }

                //Clean.. soo clean
                minPoint.Dispose();
                maxPoint.Dispose();
            }
            Location aMinPoint = new Location(minX, minY, minZ);
            Location aMaxPoint = new Location(maxX, maxY, maxZ);

            return(new Location[] { aMinPoint, aMaxPoint });
        }
コード例 #6
0
 public void scale(double amt)
 {
     min.setX(min.getX() * amt).setY(min.getY() * amt).setZ(min.getZ() * amt);
     max.setX(max.getX() * amt).setY(max.getY() * amt).setZ(max.getZ() * amt);
 }
コード例 #7
0
ファイル: Vertice.cs プロジェクト: YourWishes/FaultEnginev3
 public Vertice(Location l) : this()
 {
     this.x = l.getX();
     this.y = l.getY();
     this.z = l.getZ();
 }