Exemple #1
0
        }                                     //грани

        //public MBox(MPoint leftFaceCorner, float length, float width, float height) : base(leftFaceCorner.X, leftFaceCorner.Y, leftFaceCorner.Z)
        //{
        //    SetParameters(length, width, height);

        //    InitVertices(leftFaceCorner, length, width, height);
        //    InitFacets(Vertices);
        //}

        public MBox(MPoint center, float length, float width, float height) : base(center.X, center.Y, center.Z)
        {
            SetParameters(length, width, height);

            InitVerticesCenter(center, length, width, height);
            InitFacets(Vertices);
        }
Exemple #2
0
        }                                    //грани оснований 72

        public MCylinder(MPoint centerBot, float radius, float heigth)
        {
            CenterBot = centerBot;

            Radius = radius;

            Heigth = heigth;
        }
Exemple #3
0
        private MPoint[] GetVerticesFromCenter(MPoint center, float length, float width, float height)
        {
            const int verticesCount = 8;

            Vertices = new MPoint[verticesCount];

            float halfLength = length / 2,
                  halfWidth  = width / 2;

            for (int i = 0; i < verticesCount; ++i)
            {
                MPoint vertex = null;

                float halfHeight = i >= verticesCount / 2 ? height / 2 : -height / 2;

                // Calculates new vertices counterclockwise
                switch (i % 4)
                {
                //Left front corner
                case 0:
                    vertex = new MPoint(-halfLength, -halfWidth, halfHeight);
                    break;

                //Right front corner
                case 1:
                    vertex = new MPoint(halfLength, -halfWidth, halfHeight);
                    break;

                //Right rear corner
                case 2:
                    vertex = new MPoint(halfLength, halfWidth, halfHeight);
                    break;

                //Left rear corner
                case 3:
                    vertex = new MPoint(-halfLength, halfWidth, halfHeight);
                    break;

                default:
                    throw new Exception("Error while trying to initialize MBox vertices");
                }

                Vertices[i] = vertex;
            }

            return(Vertices);
        }
Exemple #4
0
        private void InitVertices(MPoint leftFrontCorner, float length, float width, float height)
        {
            int verticesCount = 8;

            Vertices = new MPoint[verticesCount];

            Vertices[0] = leftFrontCorner;

            for (int i = 1; i < verticesCount; ++i)
            {
                MPoint vertex = null;

                float applyingHeight = i >= verticesCount / 2 ? height : 0;

                // Calculates new vertices counterclockwise
                switch (i % 4)
                {
                //Left front corner
                case 0:
                    vertex = new MPoint(leftFrontCorner.SX, leftFrontCorner.SY, leftFrontCorner.SZ + applyingHeight);
                    break;

                //Right front corner
                case 1:
                    vertex = new MPoint(leftFrontCorner.SX + length, leftFrontCorner.SY, leftFrontCorner.SZ + applyingHeight);
                    break;

                //Right rear corner
                case 2:
                    vertex = new MPoint(leftFrontCorner.SX + length, leftFrontCorner.SY + width, leftFrontCorner.SZ + applyingHeight);
                    break;

                //Left rear corner
                case 3:
                    vertex = new MPoint(leftFrontCorner.SX, leftFrontCorner.SY + width, leftFrontCorner.SZ + applyingHeight);
                    break;

                default:
                    throw new Exception("Error while trying to initialize MBox vertices");
                }

                Vertices[i] = vertex;
            }
        }
Exemple #5
0
        public virtual MPoint GetCenterPoint()
        {
            var vertices = GetVertices();

            if (vertices.Count == 0)
            {
                throw new NullReferenceException("Shape doesn't have verices");
            }

            MPoint maxCoords = new MPoint(vertices[0].X, vertices[0].Y, vertices[0].Z);
            MPoint minCoords = new MPoint(vertices[0].X, vertices[0].Y, vertices[0].Z);

            foreach (MPoint vertex in vertices)
            {
                CompareAndSetMaxCoords(vertex, maxCoords);
                CompareAndSetMinCoords(vertex, minCoords);
            }

            return(new MPoint((maxCoords.X + minCoords.X) / 2, (maxCoords.Y + minCoords.Y) / 2, (maxCoords.Z + minCoords.Z) / 2));
        }
Exemple #6
0
 private void InitVerticesCenter(MPoint center, float length, float width, float height)
 {
     Vertices = GetVerticesFromCenter(center, length, width, height);
 }
Exemple #7
0
 private void CompareAndSetMinCoords(MPoint sourcePoint, MPoint destinationPoint)
 {
     destinationPoint.X = sourcePoint.X < destinationPoint.X ? sourcePoint.X : destinationPoint.X;
     destinationPoint.Y = sourcePoint.Y < destinationPoint.Y ? sourcePoint.Y : destinationPoint.Y;
     destinationPoint.Z = sourcePoint.Z < destinationPoint.Z ? sourcePoint.Z : destinationPoint.Z;
 }
Exemple #8
0
 public MSideCylinder(MPoint centerBot, float radius, float heigth) : base(centerBot, radius, heigth)
 {
 }
Exemple #9
0
        public MFacet(MPoint first, MPoint second, MPoint third, int argb)
        {
            Vertices = new MPoint[] { first, second, third };

            Argb = argb;
        }
Exemple #10
0
        }                              //цвет грани

        public MFacet(MPoint first, MPoint second, MPoint third) : base()
        {
            Vertices = new MPoint[] { first, second, third };
        }