public void Translate(Vector translate)
 {
     IMathTransform transform = MathUtility.CreateTransform(null);
         double[] matrix = transform.ArrayData as double[];
         matrix[9] = translate.X;
         matrix[10] = translate.Y;
         matrix[11] = translate.Z;
         Transform = MathUtility.CreateTransform(matrix);
 }
        public void SetupCorpusSize()
        {
            int i;
            Box[] boxes = { planeLocator.LBox, prismLocator1.LBox, prismLocator2.LBox };
            Box boundingBox = new Box();
            i = 0; boundingBox.Xmin = new double[] { boxes[0].CoordinatesCorners[i], boxes[1].CoordinatesCorners[i], boxes[2].CoordinatesCorners[i] }.Min();
            i = 1; boundingBox.Ymin = new double[] { boxes[0].CoordinatesCorners[i], boxes[1].CoordinatesCorners[i], boxes[2].CoordinatesCorners[i] }.Min();
            i = 2; boundingBox.Zmin = new double[] { boxes[0].CoordinatesCorners[i], boxes[1].CoordinatesCorners[i], boxes[2].CoordinatesCorners[i] }.Min();
            i = 3; boundingBox.Xmax = new double[] { boxes[0].CoordinatesCorners[i], boxes[1].CoordinatesCorners[i], boxes[2].CoordinatesCorners[i] }.Max();
            i = 4; boundingBox.Ymax = new double[] { boxes[0].CoordinatesCorners[i], boxes[1].CoordinatesCorners[i], boxes[2].CoordinatesCorners[i] }.Max();
            i = 5; boundingBox.Zmax = new double[] { boxes[0].CoordinatesCorners[i], boxes[1].CoordinatesCorners[i], boxes[2].CoordinatesCorners[i] }.Max();

            int width = Convert.ToInt32(1000.0 * (boundingBox.Zmax - boundingBox.Zmin));
            int length = Convert.ToInt32(1000.0 * (boundingBox.Xmax - boundingBox.Xmin));
            int size = Math.Max(width, length);

            Vector newLocation = new Vector()
            {
                X = (boundingBox.Xmin + boundingBox.Xmax) / 2,
                Y = (boundingBox.Ymin + boundingBox.Ymax) / 2,
                Z = (boundingBox.Zmin + boundingBox.Zmax) / 2
            };

            corpus.Translate(newLocation);
            corpus.SetParameter(configuration[Property.PARAMETER_CORPUS_WIDTH], size.ToString());
            corpus.SetParameter(configuration[Property.PARAMETER_CORPUS_LENGTH], size.ToString());

            Rebuild();
        }
        private IFace2 FindVecticalExtremeFaceWithNormal(int direction)
        {
            IFace2 extremeFace = null;
            Vector extreme = new Vector(0.0, direction * double.MinValue, 0.0);
            IMathVector targetNormalVector = MathUtility.CreateVector(new double[] { 0.0, direction, 0.0 });
            for (int i = 0; i < Faces.Length; ++i)
            {
                IFace2 face = Faces[i];
                if (face.IGetSurface().IsPlane())
                {
                    double[] normal = Helper.Instance.ApplyTransform(Transform, face.Normal);
                    IMathVector normalVector = MathUtility.CreateVector(normal);
                    if (IsHorizontal(normalVector) || IsHorizontal(Helper.Negative(normalVector)))
                    {
                        Vector center = new Box(Helper.ApplyTransform(Transform, face.GetBox())).Center;
                        if (direction == 1 ? center.Y > extreme.Y : center.Y < extreme.Y)
                        {
                            extreme.Y = center.Y;
                            extremeFace = face;
                        }
                    }
                }
            }

            return extremeFace;
        }