예제 #1
0
        public static IPolyhedron3D CreateCubes(
            double a, double b, double c,
            HomogeneousPoint3D geometricCenter,
            HomogeneousPoint3D rotationCenter)
        {
            var cubes = new List <IPolyhedron3D>
            {
                CreateParallelepiped(
                    a, b, c,
                    new HomogeneousPoint3D(0, 0, 0, 1),
                    new HomogeneousPoint3D(rotationCenter.X, rotationCenter.Y, rotationCenter.Z, rotationCenter.W),
                    new [] { 1, 2, 4 }),
                CreateParallelepiped(
                    a, b, c,
                    new HomogeneousPoint3D(a, 0, 0, 1),
                    new HomogeneousPoint3D(rotationCenter.X, rotationCenter.Y, rotationCenter.Z, rotationCenter.W),
                    new [] { 3 }),
                CreateParallelepiped(
                    a, b, c,
                    new HomogeneousPoint3D(0, 0, c, 1),
                    new HomogeneousPoint3D(rotationCenter.X, rotationCenter.Y, rotationCenter.Z, rotationCenter.W),
                    new [] { 0 }),
                CreateParallelepiped(
                    a, b, c,
                    new HomogeneousPoint3D(0, -b, 0, 1),
                    new HomogeneousPoint3D(rotationCenter.X, rotationCenter.Y, rotationCenter.Z, rotationCenter.W),
                    new [] { 5 }),
            };

            var result = new CompositePolyhedron3D(rotationCenter, new HomogeneousPoint3D(a / 2, -b / 2, c / 2, 1), cubes, (0, 0));

            MovePolyhedronGeometricCenter(new HomogeneousPoint3D(a / 2, -b / 2, c / 2, 1), geometricCenter, result);

            return(result);
        }
예제 #2
0
        private static IPolyhedron3D CreateParallelepipedWithHole(
            double a, double b, double c,
            HomogeneousPoint3D geometricCenter,
            HomogeneousPoint3D rotationCenter,
            double distance, bool showInvisibleFacets)
        {
            var parallelepiped = new List <IPolyhedron3D>
            {
                CreateParallelepiped(
                    a / 3, b, c / 3,
                    new HomogeneousPoint3D(0, 0, -2 * c / 6 - distance, 1),
                    new HomogeneousPoint3D(rotationCenter.X, rotationCenter.Y, rotationCenter.Z, rotationCenter.W),
                    showInvisibleFacets ? new int[0] : new [] { 2, 3 }),
                CreateParallelepiped(
                    a / 3, b, c / 3,
                    new HomogeneousPoint3D(0, 0, 2 * c / 6 + distance, 1),
                    new HomogeneousPoint3D(rotationCenter.X, rotationCenter.Y, rotationCenter.Z, rotationCenter.W),
                    showInvisibleFacets ? new int[0] : new [] { 2, 3 }),
                CreateParallelepiped(
                    a / 3, b, c / 3,
                    new HomogeneousPoint3D(-2 * a / 6 - distance, 0, 0, 1),
                    new HomogeneousPoint3D(rotationCenter.X, rotationCenter.Y, rotationCenter.Z, rotationCenter.W),
                    showInvisibleFacets ? new int[0] : new [] { 0, 1 }),
                CreateParallelepiped(
                    a / 3, b, c / 3,
                    new HomogeneousPoint3D(2 * a / 6 + distance, 0, 0, 1),
                    new HomogeneousPoint3D(rotationCenter.X, rotationCenter.Y, rotationCenter.Z, rotationCenter.W),
                    showInvisibleFacets ? new int[0] : new [] { 0, 1 }),
                CreateParallelepiped(
                    a / 3, b, c / 3,
                    new HomogeneousPoint3D(-2 * a / 6 - distance, 0, -2 * c / 6 - distance, 1),
                    new HomogeneousPoint3D(rotationCenter.X, rotationCenter.Y, rotationCenter.Z, rotationCenter.W),
                    showInvisibleFacets ? new int[0] : new [] { 1, 2 }),
                CreateParallelepiped(
                    a / 3, b, c / 3,
                    new HomogeneousPoint3D(2 * a / 6 + distance, 0, -2 * c / 6 - distance, 1),
                    new HomogeneousPoint3D(rotationCenter.X, rotationCenter.Y, rotationCenter.Z, rotationCenter.W),
                    showInvisibleFacets ? new int[0] : new [] { 1, 3 }),
                CreateParallelepiped(
                    a / 3, b, c / 3,
                    new HomogeneousPoint3D(2 * a / 6 + distance, 0, 2 * c / 6 + distance, 1),
                    new HomogeneousPoint3D(rotationCenter.X, rotationCenter.Y, rotationCenter.Z, rotationCenter.W),
                    showInvisibleFacets ? new int[0] : new [] { 0, 3 }),
                CreateParallelepiped(
                    a / 3, b, c / 3,
                    new HomogeneousPoint3D(-2 * a / 6 - distance, 0, 2 * c / 6 + distance, 1),
                    new HomogeneousPoint3D(rotationCenter.X, rotationCenter.Y, rotationCenter.Z, rotationCenter.W),
                    showInvisibleFacets ? new int[0] : new [] { 0, 2 }),
            };

            var result = new CompositePolyhedron3D(rotationCenter, new HomogeneousPoint3D(0, 0, 0, 1), parallelepiped, (0, 1));

            MovePolyhedronGeometricCenter(new HomogeneousPoint3D(0, 0, 0, 1), geometricCenter, result);

            return(result);
        }
        public override void AddObject(IPolyhedron3D obj)
        {
            _objects.Add(obj);

            CalculateObjectsPosition();

            _compositeObject = new CompositePolyhedron3D(
                new HomogeneousPoint3D(0, 0, 0, 1),
                new HomogeneousPoint3D(0, 0, 0, 1),
                _objects.ToArray(),
                (0, 0));

            _observerPosition = new HomogeneousPoint3D(0, 0, -Radius, 1);
            MoveObserverToTransformation(_observerPosition, _compositeObject);
        }