public void TestMultipatchConversionWithTriangleStrip()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 0.0),
                new Rectangular(0.0, 1.0),
                new Rectangular(1.0, 0.0),
                new Rectangular(1.0, 1.0),
                new Rectangular(2.0, 0.0),
                new Rectangular(2.0, 1.0),
                new Rectangular(3.0, 0.0)
            };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 3.0, 1.0);

            int[] parts = new int[] { 0 };
            MultiPatchPartType[] partTypes = new MultiPatchPartType[] { MultiPatchPartType.TriangleStrip };

            double[] zValues  = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 };
            double[] measures = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures);
            MultiPatch      patch      = new MultiPatch(multipatch, m_document, Color.Blue);

            patch.Write();
            string result          = m_stringWriter.ToString();
            Regex  trianglePattern = new Regex(m_trianglePattern);

            Assert.AreEqual(5, trianglePattern.Matches(result).Count);
        }
        public void TestMultipatchConversionWithInnerAndOuterRings()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 5.0),
                new Rectangular(5.0, 10.0),
                new Rectangular(10.0, 5.0),
                new Rectangular(5.0, 0.0),
                new Rectangular(0.0, 5.0),

                new Rectangular(2.0, 5.0),
                new Rectangular(5.0, 2.0),
                new Rectangular(8.0, 5.0),
                new Rectangular(5.0, 8.0),
                new Rectangular(2.0, 5.0),
            };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);

            int[] parts = new int[] { 0, 5 };
            MultiPatchPartType[] partTypes = new MultiPatchPartType[] { MultiPatchPartType.OuterRing, MultiPatchPartType.InnerRing };

            double[] zValues  = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
            double[] measures = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures);
            MultiPatch      patch      = new MultiPatch(multipatch, m_document, Color.Blue);

            patch.Write();
            string result = m_stringWriter.ToString();

            Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(result, m_polygonPattern));
        }
예제 #3
0
        public override void FireInternal()
        {
            activeBlades.ForEach(b => { if (b.Lifetime.IsExpired == false)
                                        {
                                            b.Lifetime.Dispose();
                                        }
                                 });
            activeBlades.Clear();

            Sound.Play("sword");
            for (var i = 1; i < 1 + SpaceExtensions.NormalizeQuantity(Range, CalculateAngleToTarget()); i++)
            {
                var location  = Holder.Center().MoveTowards(CalculateAngleToTarget(), i);
                var newBounds = Rectangular.Create(location.Left - .5f, location.Top - .5f, 1, 1);
                if (SpaceTime.CurrentSpaceTime.IsInBounds(newBounds))
                {
                    var blade = new Blade()
                    {
                        Holder = this.Holder
                    };
                    var holderLocation = Holder.TopLeft();
                    blade.MoveTo(newBounds.Left, newBounds.Top);
                    SpaceTime.CurrentSpaceTime.Add(blade);
                    activeBlades.Add(blade);
                }
            }
        }
        public void TestPolygonZValues()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 5.0),
                new Rectangular(5.0, 10.0),
                new Rectangular(10.0, 5.0),
                new Rectangular(5.0, 0.0),
                new Rectangular(0.0, 5.0),

                new Rectangular(2.0, 5.0),
                new Rectangular(5.0, 2.0),
                new Rectangular(8.0, 5.0),
                new Rectangular(5.0, 8.0),
                new Rectangular(2.0, 5.0),
            };

            double[] zValues = new double[] {
                1.0, 2.0, 3.0, 4.0, 1.0,
                5.0, 6.0, 7.0, 8.0, 5.0
            };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);

            int[]    parts    = new int[] { 0, 5 };
            double[] measures = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            PolygonZShape polygonZShape = new PolygonZShape(0, m_metadata, extent, parts, positions, 1.0, 8.0, zValues, 0.0, 0.0, measures);
            Polygon       polygon       = new Polygon(polygonZShape, m_document, Color.Blue);

            polygon.Write();
            string result = m_stringWriter.ToString();

            Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(result, m_polygonPattern));
        }
예제 #5
0
        public PolygonZShape(
            int recordNumber,
            StringDictionary metadata,
            CartographicExtent extent,
            int[] parts,
            Rectangular[] positions,
            double minimumZ,
            double maximumZ,
            double[] zValues,
            double minimumMeasure,
            double maximumMeasure,
            double[] measures,
            ShapeType shapeType = ShapeType.PolygonZ
            )
            : base(recordNumber, metadata, extent, parts, positions, minimumMeasure, maximumMeasure, measures, shapeType)
        {
            _minimumZ = minimumZ;
            _maximumZ = maximumZ;

            for (int i = 0; i < parts.Length; ++i)
            {
                int count = ((i == parts.Length - 1) ?
                    positions.Length : parts[i + 1]) - parts[i];

                _parts[i] = new ShapePart(positions, zValues, measures, parts[i], count);
            }
        }
예제 #6
0
 /// <summary>
 /// Writes a <see cref="Rectangular"/> value as an array in X, Y order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteCartesian2(CesiumOutputStream output, Rectangular value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.X);
     output.WriteValue(value.Y);
     output.WriteEndSequence();
 }
        public void TestWriteCheckerboardMaterial()
        {
            var expectedEvenColor = Color.Red;
            var expectedOddColor  = Color.Blue;
            var expectedRepeat    = new Rectangular(3.5, 4.5);

            using (Packet)
                using (var polyline = Packet.OpenPolylineProperty())
                    using (var material = polyline.OpenMaterialProperty())
                        using (var checkerboardMaterial = material.OpenCheckerboardProperty())
                        {
                            checkerboardMaterial.WriteEvenColorProperty(expectedEvenColor);
                            checkerboardMaterial.WriteOddColorProperty(expectedOddColor);
                            checkerboardMaterial.WriteRepeatProperty(expectedRepeat);
                        }

            AssertExpectedJson(PacketCesiumWriter.PolylinePropertyName, new Dictionary <string, object>
            {
                {
                    PolylineCesiumWriter.MaterialPropertyName, new Dictionary <string, object>
                    {
                        {
                            PolylineMaterialCesiumWriter.CheckerboardPropertyName, new Dictionary <string, object>
                            {
                                { CheckerboardMaterialCesiumWriter.EvenColorPropertyName, expectedEvenColor },
                                { CheckerboardMaterialCesiumWriter.OddColorPropertyName, expectedOddColor },
                                { CheckerboardMaterialCesiumWriter.RepeatPropertyName, expectedRepeat },
                            }
                        },
                    }
                },
            });
        }
예제 #8
0
        public Rectangular Rectangular(string Values)
        {
            Rectangular rec = new Rectangular();

            string[] MaxValues = Values.Split(" ");

            if (MaxValues.Length != 2)
            {
                Console.WriteLine(Messages.ErrorRectangular);
            }
            else if (Control(MaxValues, null) == false)
            {
                Console.WriteLine(Messages.ErrorValue);
            }
            else if (Convert.ToInt32(MaxValues[0]) < 0 || Convert.ToInt32(MaxValues[1]) < 0)
            {
                Console.WriteLine(Messages.ErrorInput);
            }
            else
            {
                rec.Xmax = Convert.ToInt32(MaxValues[0]);
                rec.Ymax = Convert.ToInt32(MaxValues[1]);
            }
            return(rec);
        }
예제 #9
0
        public PolygonShape(
            int recordNumber,
            StringDictionary metadata,
            CartographicExtent extent,
            int[] parts,
            Rectangular[] positions,
            ShapeType shapeType = ShapeType.Polygon)
            : base(recordNumber, metadata, shapeType)
        {
            _extent = new CartographicExtent(
                extent.WestLongitude * Constants.RadiansPerDegree,
                extent.SouthLatitude * Constants.RadiansPerDegree,
                extent.EastLongitude * Constants.RadiansPerDegree,
                extent.NorthLatitude * Constants.RadiansPerDegree);

            for (int i = 0; i < positions.Length; i++)
            {
                positions[i] = new Rectangular(positions[i].X * Constants.RadiansPerDegree, positions[i].Y * Constants.RadiansPerDegree);
            }

            _parts = new List <ShapePart>(parts.Length);
            for (int i = 0; i < parts.Length; ++i)
            {
                int count = ((i == parts.Length - 1) ?
                             positions.Length : parts[i + 1]) - parts[i];

                _parts.Add(new ShapePart(positions, parts[i], count));
            }
        }
예제 #10
0
        static void Main(string[] args)
        {
            var shape = new Shape();
            var elip  = new Elipse();
            var r     = new Rectangular();



            elip.Position.X = 2;
            elip.Position.Y = 2;


            r.Position.X  = 1;
            r.Position.Y  = 1;
            r.Size.Width  = 10;
            r.Size.Height = 10;

            r.Draw();

            elip.Greet("Bartek");
            shape.Greet("Bartek");
            GreetShape(elip);
            GreetShape(r);
            GreetShape(shape);

            elip.ElipDraw();

            Console.ReadKey();
        }
예제 #11
0
 /// <summary>
 /// Writes a <see cref="Rectangular"/> value as an array in X, Y order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteCartesian2(CesiumOutputStream output, Rectangular value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.X);
     output.WriteValue(value.Y);
     output.WriteEndSequence();
 }
        public void TestMultipatchConversionWithMultipleRings()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 5.0),
                new Rectangular(5.0, 10.0),
                new Rectangular(10.0, 5.0),
                new Rectangular(5.0, 0.0),
                new Rectangular(0.0, 5.0),

                new Rectangular(2.0, 5.0),
                new Rectangular(5.0, 2.0),
                new Rectangular(8.0, 5.0),
                new Rectangular(5.0, 8.0),
                new Rectangular(2.0, 5.0),
            };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);

            int[] parts = new int[] { 0, 5 };
            MultiPatchPartType[] partTypes = new MultiPatchPartType[] { MultiPatchPartType.Ring, MultiPatchPartType.Ring };

            double[] zValues  = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
            double[] measures = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures);
            MultiPatch      patch      = new MultiPatch(multipatch, m_document, Color.Blue);

            patch.Write();
            string result         = m_stringWriter.ToString();
            Regex  polygonPattern = new Regex(m_polygonPattern);

            Assert.AreEqual(2, polygonPattern.Matches(result).Count);
        }
예제 #13
0
        public static Shaped CreateShape(string shaped)
        {
            Shaped shap = null;

            switch (shaped)
            {
            case "circle":
                Console.WriteLine("请输入圆的半径");
                double Rad = Convert.ToDouble(Console.ReadLine());
                shap = new Circle(Rad);
                break;

            case "rectangular":
                Console.WriteLine("请输入矩形的长和宽");
                double Len = Convert.ToDouble(Console.ReadLine());
                double Wid = Convert.ToDouble(Console.ReadLine());
                shap = new Rectangular(Len, Wid);
                break;

            case "triangle":
                Console.WriteLine("请输入三角形的三边长");
                double Ed1 = Convert.ToDouble(Console.ReadLine());
                double Ed2 = Convert.ToDouble(Console.ReadLine());
                double Ed3 = Convert.ToDouble(Console.ReadLine());
                shap = new Triangle(Ed1, Ed2, Ed3);
                break;

            case "square":
                Console.WriteLine("请输入正方形的边长");
                double Ed0 = Convert.ToDouble(Console.ReadLine());
                shap = new Square(Ed0);
                break;
            }
            return(shap);
        }
예제 #14
0
        public void Work()
        {
            var angleToTarget = Me.CalculateAngleTo(Me.Target);
            var oppositeAngle = angleToTarget;// SpaceExtensions.GetOppositeAngle(angleToTarget);
            var newLocation   = SpaceExtensions.MoveTowards(Me.TopLeft(), oppositeAngle, 1);
            var overlapCount  = SpaceTime.CurrentSpaceTime.Elements.Where(e => Rectangular.Create(newLocation.Left, newLocation.Top, 1, 1).OverlapPercentage(e) > 0).Count();

            if (overlapCount == 0)
            {
                Me.MoveTo(newLocation.Left, newLocation.Top);
            }
        }
예제 #15
0
        public void ToFromDataTable_CycleTest(int m, int n, int timesToRun)
        {
            Rectangular rand = new Rectangular();

            for (int i = 0; i < timesToRun; i++)
            {
                Matrix3   A              = rand.Randomfloat(m, n);
                DataTable dt             = A.ToDataTable();
                Matrix3   AReconstituted = A.FromDataTable(dt);
                Assert.That(AReconstituted, Is.EqualTo(A));
            }
        }
예제 #16
0
        public List <ISection> GetConcreteFrameSection(string[] dummy,
                                                       string FrameName, string Temp_material, Material Material_dummy,
                                                       int inicio, int fin, ISection framei,
                                                       int indiceM, int indiceB,
                                                       Modelo_Etabs modelo, List <string> E2KFile)
        {
            var             Temp             = E2KFile.GetRange(inicio, fin - inicio).FindAll(x => x.Contains(" MATERIAL "));
            List <ISection> concreteSections = new List <ISection>();

            foreach (string Linea in Temp)
            {
                dummy         = Linea.Split();
                Temp_material = dummy[7].Replace("\"", "");

                if (modelo.Materials.Exists(x => x.Material_name == Temp_material))
                {
                    var prueba = from Material materiali in modelo.Materials
                                 where materiali.Material_name == Temp_material
                                 select materiali;

                    Material_dummy = prueba.FirstOrDefault();

                    if (Material_dummy.tipo_Material == Enum_Material.Concrete)

                    {
                        FrameName = dummy[4].Replace("\"", "");
                        var   FrameSection = dummy[indiceM].ToLower().Replace("\"", "");
                        float h, b;

                        switch (FrameSection)
                        {
                        case "rectangular":
                            h      = float.Parse(dummy[indiceB]);
                            b      = float.Parse(dummy[16]);
                            framei = new Rectangular(FrameName, b, h, Material_dummy, Enum_Seccion.Rectangular);
                            break;

                        case "circular":
                            h      = float.Parse(dummy[indiceB]);
                            framei = new Circular(FrameName, h, Material_dummy, Enum_Seccion.Circular);
                            break;

                        //No hacer nada por el momento hasta saber como lo modelan
                        case "sd":
                            break;
                        }
                        concreteSections.Add(framei);
                    }
                }
            }
            return(concreteSections);
        }
예제 #17
0
        public void ToMatLabStringParse_CycleTest(int m, int n, int timesToRun)
        {
            Rectangular rand = new Rectangular();

            for (int i = 0; i < timesToRun; i++)
            {
                Matrix3 A              = rand.Randomfloat(m, n);
                string  strA           = A.ToMatLabString();
                Matrix3 AReconstituted = new Matrix3();
                AReconstituted.ParseMatLab(strA);
                Assert.That(AReconstituted, Is.EqualTo(A));
            }
        }
예제 #18
0
        //Main begins program execution
        static void Main(string[] args)
        {
            //Define variables of two rectangulars
            double length1 = 5;
            double width1  = 5;
            double length2 = 4;
            double width2  = 5;

            //Create two instnaces of Rectangular class
            Rectangular rectangular1 = new Rectangular(length1, width1);
            Rectangular rectangular2 = new Rectangular(length2, width2);

            bool identical = RectangularComparator(rectangular1, rectangular2);
        }
예제 #19
0
        static void Main(string[] args)
        {
            Triangle    t1 = ShapeFactory.CtreateShape("Triangle") as Triangle;
            Rectangular r1 = ShapeFactory.CtreateShape("Rectangular") as Rectangular;
            Square      s1 = ShapeFactory.CtreateShape("Square") as Square;

            s1.Size = 3;//更新边长而不更新面积,制造错误,使SelfCheck()返回值为false;

            Console.WriteLine(t1.ToString());
            Console.WriteLine("====================");
            Console.WriteLine(r1.ToString());
            Console.WriteLine("====================");
            Console.WriteLine(s1.ToString());
        }
예제 #20
0
        private Profile NewProfile(Profile oriProfile, ProfileType newProfileType)
        {
            Profile newP;

            switch (newProfileType)
            {
            case ProfileType.T:
                newP = new TT(oriProfile.Name, width: 1, height: 0.8, webThickness: 0.2, flangeThickness: 0.1);
                break;

            default:      //
                newP = new Rectangular(oriProfile.Name, width: 1, height: 0.8);
                break;
            }
            return(newP);
        }
예제 #21
0
        public void TestBackgroundPaddingProperty()
        {
            var expectedBackgroundPadding = new Rectangular(3, 4);

            using (Packet)
                using (var label = Packet.OpenLabelProperty())
                    using (var interval = label.OpenInterval())
                    {
                        interval.WriteBackgroundPaddingProperty(expectedBackgroundPadding);
                    }

            AssertExpectedJson(PacketCesiumWriter.LabelPropertyName, new Dictionary <string, object>
            {
                { LabelCesiumWriter.BackgroundPaddingPropertyName, expectedBackgroundPadding },
            });
        }
        public void JoinsPolygonWithMultipleHoles()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(-122.0, 37.0),
                new Rectangular(-121.9, 37.0),
                new Rectangular(-121.9, 37.1),
                new Rectangular(-122.0, 37.1),
                new Rectangular(-122.0, 37.0),

                new Rectangular(-121.99, 37.01),
                new Rectangular(-121.99, 37.04),
                new Rectangular(-121.96, 37.04),
                new Rectangular(-121.96, 37.01),
                new Rectangular(-121.99, 37.01),

                new Rectangular(-121.94, 37.06),
                new Rectangular(-121.94, 37.09),
                new Rectangular(-121.91, 37.09),
                new Rectangular(-121.91, 37.06),
                new Rectangular(-121.94, 37.06),

                new Rectangular(-121.99, 37.06),
                new Rectangular(-121.99, 37.09),
                new Rectangular(-121.96, 37.09),
                new Rectangular(-121.96, 37.06),
                new Rectangular(-121.99, 37.06),

                new Rectangular(-121.94, 37.01),
                new Rectangular(-121.94, 37.04),
                new Rectangular(-121.91, 37.04),
                new Rectangular(-121.91, 37.01),
                new Rectangular(-121.94, 37.01)
            };
            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);

            int[] parts = new int[] { 0, 5, 10, 15, 20 };

            Polygon polygon = new Polygon(new PolygonShape(0, m_metadata, extent, parts, positions), m_document, Color.Blue);

            polygon.Write();
            string result         = m_stringWriter.ToString();
            Regex  polygonPattern = new Regex(m_polygonPattern);

            Assert.AreEqual(1, polygonPattern.Matches(result).Count);
        }
예제 #23
0
        /// <summary> 构造一个默认的定义对象 </summary>
        private Definition GetInitialDefinitionObject()
        {
            Definition d;

            if (typeof(T) == typeof(Profile))
            {
                d = new Rectangular("Rec1", 1, 0.8);
            }
            else if (typeof(T) == typeof(Material))
            {
                d = new Material("Mat1", density: 1.9e3, elastic: 200e6, poissonRatio: 0.3, type: MaterialType.Elastic);
            }
            else
            {
                throw new ArgumentException();
            }
            return(d);
        }
예제 #24
0
        public MultiPatchShape(
            int recordNumber,
            StringDictionary metadata,
            CartographicExtent extent,
            int[] parts,
            MultiPatchPartType[] partTypes,
            Rectangular[] positions,
            double minimumZ,
            double maximumZ,
            double[] zValues,
            double minimumMeasure,
            double maximumMeasure,
            double[] measures,
            ShapeType shapeType = ShapeType.MultiPatch)
            : base(recordNumber, metadata, shapeType)
        {
            _extent = new CartographicExtent(
               extent.WestLongitude * Constants.RadiansPerDegree,
               extent.SouthLatitude * Constants.RadiansPerDegree,
               extent.EastLongitude * Constants.RadiansPerDegree,
               extent.NorthLatitude * Constants.RadiansPerDegree);

            _minimumZ = minimumZ;
            _maximumZ = maximumZ;
            _minimumMeasure = minimumMeasure;
            _maximumMeasure = maximumMeasure;
            _measures = (double[])measures.Clone();

            for (int i = 0; i < positions.Length; i++)
            {
                positions[i] = new Rectangular(positions[i].X * Constants.RadiansPerDegree, positions[i].Y * Constants.RadiansPerDegree);
            }

            _parts = new ShapePart[parts.Length];
            for (int i = 0; i < parts.Length; ++i)
            {
                int count = ((i == parts.Length - 1) ?
                    positions.Length : parts[i + 1]) - parts[i];

                _parts[i] = new ShapePart(positions, zValues, parts[i], count);
            }

            _partTypes = (MultiPatchPartType[])partTypes.Clone();
        }
예제 #25
0
        public MultiPatchShape(
            int recordNumber,
            StringDictionary metadata,
            CartographicExtent extent,
            int[] parts,
            MultiPatchPartType[] partTypes,
            Rectangular[] positions,
            double minimumZ,
            double maximumZ,
            double[] zValues,
            double minimumMeasure,
            double maximumMeasure,
            double[] measures,
            ShapeType shapeType = ShapeType.MultiPatch)
            : base(recordNumber, metadata, shapeType)
        {
            _extent = new CartographicExtent(
                extent.WestLongitude * Constants.RadiansPerDegree,
                extent.SouthLatitude * Constants.RadiansPerDegree,
                extent.EastLongitude * Constants.RadiansPerDegree,
                extent.NorthLatitude * Constants.RadiansPerDegree);

            _minimumZ       = minimumZ;
            _maximumZ       = maximumZ;
            _minimumMeasure = minimumMeasure;
            _maximumMeasure = maximumMeasure;
            _measures       = (double[])measures.Clone();

            for (int i = 0; i < positions.Length; i++)
            {
                positions[i] = new Rectangular(positions[i].X * Constants.RadiansPerDegree, positions[i].Y * Constants.RadiansPerDegree);
            }

            _parts = new ShapePart[parts.Length];
            for (int i = 0; i < parts.Length; ++i)
            {
                int count = ((i == parts.Length - 1) ?
                             positions.Length : parts[i + 1]) - parts[i];

                _parts[i] = new ShapePart(positions, zValues, parts[i], count);
            }

            _partTypes = (MultiPatchPartType[])partTypes.Clone();
        }
        public void TestPolylineZValues()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 0.0),
                new Rectangular(1.0, 1.0),
                new Rectangular(2.0, 2.0),
                new Rectangular(3.0, 3.0),
            };

            double[] zValues = new double[] { 0.0, 1.0, 2.0, 3.0 };
            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 3.0, 3.0);
            int[] parts = new int[] { 0 };
            double[] measures = new double[] { 0.0, 0.0, 0.0, 0.0 };

            PolylineZShape polylineZShape = new PolylineZShape(0, new StringDictionary(), extent, parts, positions, 1.0, 8.0, zValues, 0.0, 0.0, measures);
            Polyline polyline = new Polyline(polylineZShape, m_document, Color.Blue);
            polyline.Write();
            string result = m_stringWriter.ToString();
            Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(result, m_polylinePattern));
        }
예제 #27
0
        static void Main(string[] args)
        {
            bool inputError;
            int  UserInputSideA;

            do
            {
                inputError = false;
                try
                {
                    List <GeometriForm> sqList = new List <GeometriForm>();
                    GeometriForm        sq     = new Square(10);
                    sqList.Add(sq);
                    GeometriForm rec = new Rectangular(10, 5);
                    sqList.Add(rec);
                    GeometriForm paral = new Parallelogram(3, 5, 20);
                    sqList.Add(paral);
                    GeometriForm trapez = new Trapez(10, 9, 8, 9);
                    sqList.Add(trapez);
                    GeometriForm triangle = new Triangle(10, 5, 2);
                    sqList.Add(triangle);


                    foreach (GeometriForm item in sqList)
                    {
                        Console.WriteLine("Type: " + item.ToString());
                        Console.WriteLine("The perimeter of the square is: " + item.GetPerimiter());
                        Console.WriteLine("The area of the square is: " + item.GetArea());
                        Console.WriteLine("___________________________________________");
                        Console.WriteLine();
                    }

                    Console.ReadKey();
                }
                catch (Exception)
                {
                    Console.WriteLine("Not a valid input try again:");
                    inputError = true;
                }
            } while (inputError);
        }
예제 #28
0
        public void Random_NByN_NonSymetric(int n)
        {
            Rectangular rand = new Rectangular();
            Matrix3     A    = rand.Randomfloat(n, n);

            EigenvalueDecomposition EofA = new EigenvalueDecomposition(A);

            Matrix3 V = EofA.V;


            Matrix3 D    = EofA.getD();
            Matrix3 test = Matrix3.Mult(D, V.Inverted());

            test = Matrix3.Mult(V, test);
            // V*D * V.Inverse = A
            test = Matrix3.Mult(D, V.Inverted());
            test = Matrix3.Mult(V, test);
            Assert.That(test.ToFloatArray(), Is.EqualTo(A.ToFloatArray()).Within(.0000001).Percent);
            // A.times(V) equals V.times(D)
            Assert.That(Matrix3.Mult(A, V).ToFloatArray(), Is.EqualTo(Matrix3.Mult(V, D).ToFloatArray()).Within(.0000001).Percent);
        }
        public void TestWriteGridMaterial()
        {
            var          expectedColor         = Color.Red;
            const double expectedCellAlpha     = 0.7;
            var          expectedLineCount     = new Rectangular(6, 3);
            var          expectedLineThickness = new Rectangular(3, 4);
            var          expectedLineOffset    = new Rectangular(5, 9);

            using (Packet)
                using (var polyline = Packet.OpenPolylineProperty())
                    using (var material = polyline.OpenMaterialProperty())
                        using (var gridMaterial = material.OpenGridProperty())
                        {
                            gridMaterial.WriteColorProperty(expectedColor);
                            gridMaterial.WriteCellAlphaProperty(expectedCellAlpha);
                            gridMaterial.WriteLineCountProperty(expectedLineCount);
                            gridMaterial.WriteLineThicknessProperty(expectedLineThickness);
                            gridMaterial.WriteLineOffsetProperty(expectedLineOffset);
                        }

            AssertExpectedJson(PacketCesiumWriter.PolylinePropertyName, new Dictionary <string, object>
            {
                {
                    PolylineCesiumWriter.MaterialPropertyName, new Dictionary <string, object>
                    {
                        {
                            PolylineMaterialCesiumWriter.GridPropertyName, new Dictionary <string, object>
                            {
                                { GridMaterialCesiumWriter.ColorPropertyName, expectedColor },
                                { GridMaterialCesiumWriter.CellAlphaPropertyName, expectedCellAlpha },
                                { GridMaterialCesiumWriter.LineCountPropertyName, expectedLineCount },
                                { GridMaterialCesiumWriter.LineThicknessPropertyName, expectedLineThickness },
                                { GridMaterialCesiumWriter.LineOffsetPropertyName, expectedLineOffset },
                            }
                        },
                    }
                }
            });
        }
    static void Main()
    {
        Circle circle = new Circle();
        circle.x = 1;
        circle.y = 1;
        circle.radius = 1.5;

        Rectangular rect = new Rectangular();
        rect.top = 1;
        rect.left = -1;
        rect.width = 6;
        rect.height = 2;

        bool inCircle = false;
        bool inRect = false;

        double inputX = double.Parse(Console.ReadLine());
        double inputY = double.Parse(Console.ReadLine());

        if (Math.Pow((inputX - circle.x), 2) + Math.Pow((inputY - circle.y), 2) <= Math.Pow(circle.radius, 2))
        {
            inCircle = true;
        }

        if ((inputX >= rect.left && inputX <= rect.left + rect.width) &&
            (inputY <= rect.top && inputY >= rect.top - rect.height))
        {
            inRect = true;
        }

        if (inCircle == true && inRect == false)
        {
            Console.WriteLine("True");
        }
        else
        {
            Console.WriteLine("False");
        }
    }
        public void JoinsPolygonWithMultipleOuterRings()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 5.0),
                new Rectangular(5.0, 10.0),
                new Rectangular(10.0, 5.0),
                new Rectangular(5.0, 0.0),
                new Rectangular(0.0, 5.0),

                new Rectangular(2.0, 5.0),
                new Rectangular(5.0, 2.0),
                new Rectangular(8.0, 5.0),
                new Rectangular(5.0, 8.0),
                new Rectangular(2.0, 5.0),

                new Rectangular(20.0, 5.0),
                new Rectangular(25.0, 10.0),
                new Rectangular(30.0, 5.0),
                new Rectangular(25.0, 0.0),
                new Rectangular(20.0, 5.0),

                new Rectangular(22.0, 5.0),
                new Rectangular(25.0, 2.0),
                new Rectangular(28.0, 5.0),
                new Rectangular(25.0, 8.0),
                new Rectangular(22.0, 5.0)
            };
            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 30.0, 10.0);

            int[] parts = new int[] { 0, 5, 10, 15 };

            Polygon polygon = new Polygon(new PolygonShape(0, m_metadata, extent, parts, positions), m_document, Color.Blue);

            polygon.Write();
            string result         = m_stringWriter.ToString();
            Regex  polygonPattern = new Regex(m_polygonPattern);

            Assert.AreEqual(2, polygonPattern.Matches(result).Count);
        }
예제 #32
0
        public void ToStringParse_CycleTest(int m, int n, int timesToRun)
        {
            Rectangular rand = new Rectangular();


            for (int i = 0; i < timesToRun; i++)
            {
                Matrix3 A              = rand.Randomfloat(m, n);
                string  strA           = A.ToString();
                Matrix3 AReconstituted = new Matrix3();
                AReconstituted.Parse(strA);
                Assert.That(AReconstituted.ToFloatArray(), Is.EqualTo(A.ToFloatArray()));
            }

            for (int i = 0; i < timesToRun; i++)
            {
                Matrix3 A              = rand.Randomfloat(m, n);
                string  strA           = A.ToString("<", "{", "\n", ", ", "}", ">");
                Matrix3 AReconstituted = new Matrix3();
                AReconstituted.Parse(strA, "<", "{", "\n", ", ", "}", ">");
                Assert.That(AReconstituted.ToFloatArray(), Is.EqualTo(A.ToFloatArray()));
            }
        }
        public void TestPolylineZValues()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 0.0),
                new Rectangular(1.0, 1.0),
                new Rectangular(2.0, 2.0),
                new Rectangular(3.0, 3.0),
            };

            double[]           zValues = new double[] { 0.0, 1.0, 2.0, 3.0 };
            CartographicExtent extent  = new CartographicExtent(0.0, 0.0, 3.0, 3.0);

            int[]    parts    = new int[] { 0 };
            double[] measures = new double[] { 0.0, 0.0, 0.0, 0.0 };

            PolylineZShape polylineZShape = new PolylineZShape(0, new StringDictionary(), extent, parts, positions, 1.0, 8.0, zValues, 0.0, 0.0, measures);
            Polyline       polyline       = new Polyline(polylineZShape, m_document, Color.Blue);

            polyline.Write();
            string result = m_stringWriter.ToString();

            Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(result, m_polylinePattern));
        }
예제 #34
0
        public static void TestShapes()
        {
            Console.WriteLine("####################################################### \n"
                              + "testShapes()\n"
                              + "#######################################################");

            Coordinate coordinate = new Coordinate();

            coordinate.XCoordinate = 1.0;
            coordinate.YCoordinate = 2.0;

            Rectangular rectangular = new Rectangular();

            rectangular.Height         = 1.0;
            rectangular.Width          = 2.0;
            rectangular.Name           = "Rectangular";
            rectangular.Coordinate     = coordinate;
            rectangular.FillColor      = "#ffffff";
            rectangular.StrokeHexColor = "#000000";
            rectangular.Stroke         = 1;

            Circle circle = new Circle()
            {
                Coordinate     = coordinate,
                FillColor      = "#ffffff",
                Name           = "Circle",
                Radius         = 2.0,
                Stroke         = 1,
                StrokeHexColor = "#000000"
            };

            Console.WriteLine(coordinate + "\n");
            Console.WriteLine(rectangular + "\n");
            Console.WriteLine(circle + "\n");

            Console.WriteLine("#######################################################\n");
        }
예제 #35
0
파일: Program.cs 프로젝트: ming91915/SDSS
        /// <summary> 构造一个车站模型实例 </summary>
        /// <param name="sm"></param>
        public static void ConstructStationModel(Model1 sm)
        {
            //
            Material mat1 = new Material("elas1", 1900, 200e9, 0.3, MaterialType.Elastic);

            sm.Definitions.Materials.Add(mat1);
            Material mat2 = new MohrCoulomb("MC", 1900, 200e9, 0.3, 60e6, 30);

            sm.Definitions.Materials.Add(mat2);
            //
            Profile rec = new Rectangular("rec1", 0.5, 1.5);

            sm.Definitions.Profiles.Add(rec);
            Profile profT = new TT("t1", 2, 1, 0.1, 0.1);

            sm.Definitions.Profiles.Add(profT);

            //
            sm.Frame = Frame.Create(new float[] { 4, 5, 6, }, new float[] { 3, 6 }, defaultMat: mat1, defaultProfile: rec);

            //
            sm.Frame.Beams[0].Profile    = profT;
            sm.Frame.Columns[0].Material = mat2;
        }
        public void TestMultipatchConversionWithInnerAndOuterRings()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 5.0),
                new Rectangular(5.0, 10.0),
                new Rectangular(10.0, 5.0),
                new Rectangular(5.0, 0.0),
                new Rectangular(0.0, 5.0),

                new Rectangular(2.0, 5.0),
                new Rectangular(5.0, 2.0),
                new Rectangular(8.0, 5.0),
                new Rectangular(5.0, 8.0),
                new Rectangular(2.0, 5.0),
            };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);
            int[] parts = new int[] { 0, 5 };
            MultiPatchPartType[] partTypes = new MultiPatchPartType[] { MultiPatchPartType.OuterRing, MultiPatchPartType.InnerRing} ;

            double[] zValues = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
            double[] measures = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures);
            MultiPatch patch = new MultiPatch(multipatch, m_document, Color.Blue);
            patch.Write();
            string result = m_stringWriter.ToString();
            Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(result, m_polygonPattern));
        }
        public void TestMultipatchConversionWithTriangleStrip()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 0.0),
                new Rectangular(0.0, 1.0),
                new Rectangular(1.0, 0.0),
                new Rectangular(1.0, 1.0),
                new Rectangular(2.0, 0.0),
                new Rectangular(2.0, 1.0),
                new Rectangular(3.0, 0.0)
            };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 3.0, 1.0);
            int[] parts = new int[] { 0 };
            MultiPatchPartType[] partTypes = new MultiPatchPartType[] { MultiPatchPartType.TriangleStrip };

            double[] zValues = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 };
            double[] measures = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures);
            MultiPatch patch = new MultiPatch(multipatch, m_document, Color.Blue);
            patch.Write();
            string result = m_stringWriter.ToString();
            Regex trianglePattern = new Regex(m_trianglePattern);
            Assert.AreEqual(5, trianglePattern.Matches(result).Count);
        }
        public void TestPolygonZValues()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 5.0),
                new Rectangular(5.0, 10.0),
                new Rectangular(10.0, 5.0),
                new Rectangular(5.0, 0.0),
                new Rectangular(0.0, 5.0),

                new Rectangular(2.0, 5.0),
                new Rectangular(5.0, 2.0),
                new Rectangular(8.0, 5.0),
                new Rectangular(5.0, 8.0),
                new Rectangular(2.0, 5.0),
            };

            double[] zValues = new double[] {
                1.0, 2.0, 3.0, 4.0, 1.0,
                5.0, 6.0, 7.0, 8.0, 5.0
            };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);
            int[] parts = new int[] { 0, 5 };
            double[] measures = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            PolygonZShape polygonZShape = new PolygonZShape(0, m_metadata, extent, parts, positions, 1.0, 8.0, zValues, 0.0, 0.0, measures);
            Polygon polygon = new Polygon(polygonZShape, m_document, Color.Blue);
            polygon.Write();
            string result = m_stringWriter.ToString();
            Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(result, m_polygonPattern));
        }
        public void JoinsPolygonWithMultipleHoles()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(-122.0, 37.0),
                new Rectangular(-121.9, 37.0),
                new Rectangular(-121.9, 37.1),
                new Rectangular(-122.0, 37.1),
                new Rectangular(-122.0, 37.0),
                
                new Rectangular(-121.99, 37.01),
                new Rectangular(-121.99, 37.04),
                new Rectangular(-121.96, 37.04),
                new Rectangular(-121.96, 37.01),
                new Rectangular(-121.99, 37.01),
                
                new Rectangular(-121.94, 37.06),
                new Rectangular(-121.94, 37.09),
                new Rectangular(-121.91, 37.09),
                new Rectangular(-121.91, 37.06),
                new Rectangular(-121.94, 37.06),

                new Rectangular(-121.99, 37.06),
                new Rectangular(-121.99, 37.09),                
                new Rectangular(-121.96, 37.09),
                new Rectangular(-121.96, 37.06),                
                new Rectangular(-121.99, 37.06),
                                           
                new Rectangular(-121.94, 37.01),
                new Rectangular(-121.94, 37.04),
                new Rectangular(-121.91, 37.04),
                new Rectangular(-121.91, 37.01),
                new Rectangular(-121.94, 37.01)
            };
            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);
            int[] parts = new int[] { 0, 5, 10, 15, 20 };

            Polygon polygon = new Polygon(new PolygonShape(0, m_metadata, extent, parts, positions), m_document, Color.Blue);
            polygon.Write();
            string result = m_stringWriter.ToString();
            Regex polygonPattern = new Regex(m_polygonPattern);
            Assert.AreEqual(1, polygonPattern.Matches(result).Count);
        }
        public void JoinsPolygonWithMultipleOuterRings()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 5.0),
                new Rectangular(5.0, 10.0),
                new Rectangular(10.0, 5.0),
                new Rectangular(5.0, 0.0),
                new Rectangular(0.0, 5.0),

                new Rectangular(2.0, 5.0),
                new Rectangular(5.0, 2.0),
                new Rectangular(8.0, 5.0),
                new Rectangular(5.0, 8.0),
                new Rectangular(2.0, 5.0),

                new Rectangular(20.0, 5.0),
                new Rectangular(25.0, 10.0),
                new Rectangular(30.0, 5.0),
                new Rectangular(25.0, 0.0),
                new Rectangular(20.0, 5.0),

                new Rectangular(22.0, 5.0),
                new Rectangular(25.0, 2.0),
                new Rectangular(28.0, 5.0),
                new Rectangular(25.0, 8.0),
                new Rectangular(22.0, 5.0)
            };
            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 30.0, 10.0);
            int[] parts = new int[] { 0, 5, 10, 15 };

            Polygon polygon = new Polygon(new PolygonShape(0, m_metadata, extent, parts, positions), m_document, Color.Blue);
            polygon.Write();
            string result = m_stringWriter.ToString();
            Regex polygonPattern = new Regex(m_polygonPattern);
            Assert.AreEqual(2, polygonPattern.Matches(result).Count);
        }
        public void TestMultipatchConversionWithMultipleRings()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 5.0),
                new Rectangular(5.0, 10.0),
                new Rectangular(10.0, 5.0),
                new Rectangular(5.0, 0.0),
                new Rectangular(0.0, 5.0),

                new Rectangular(2.0, 5.0),
                new Rectangular(5.0, 2.0),
                new Rectangular(8.0, 5.0),
                new Rectangular(5.0, 8.0),
                new Rectangular(2.0, 5.0),
            };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);
            int[] parts = new int[] { 0, 5 };
            MultiPatchPartType[] partTypes = new MultiPatchPartType[] { MultiPatchPartType.Ring, MultiPatchPartType.Ring };

            double[] zValues = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
            double[] measures = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures);
            MultiPatch patch = new MultiPatch(multipatch, m_document, Color.Blue);
            patch.Write();
            string result = m_stringWriter.ToString();
            Regex polygonPattern = new Regex(m_polygonPattern);
            Assert.AreEqual(2, polygonPattern.Matches(result).Count);
        }