Exemple #1
0
        protected override void ProcessFigure(CircularList<Point> list,
                                              Point3DCollection vertices,
                                              Vector3DCollection normals,
                                              Int32Collection indices, 
                                              PointCollection textures)
        {
            int offset = vertices.Count;

            for (int i = 0; i <= list.Count; i++)
            {
                Point pt = list[i];

                // Set vertices.
                vertices.Add(new Point3D(pt.X, pt.Y, 0));
                vertices.Add(new Point3D(pt.X, pt.Y, -Depth));

                // Set texture coordinates.
                textures.Add(new Point((double)i / list.Count, 0));
                textures.Add(new Point((double)i / list.Count, 1));

                // Set triangle indices.
                if (i < list.Count)
                {
                    indices.Add(offset + i * 2 + 0);
                    indices.Add(offset + i * 2 + 2);
                    indices.Add(offset + i * 2 + 1);

                    indices.Add(offset + i * 2 + 1);
                    indices.Add(offset + i * 2 + 2);
                    indices.Add(offset + i * 2 + 3);
                }
            }
        }
 private void LayoutRoot_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     PointCollection points = new PointCollection();
     foreach (Point p in poly.Points)
         points.Add(p);
     Point newPoint = e.GetPosition(poly);
     points.Add(newPoint);
     poly.Points = points;
     // placeholder
     Ellipse ph = new Ellipse
     {
         Fill = new SolidColorBrush(Colors.Black),
         Width = 4D,
         Height = 4D
     };
     TranslateTransform t = new TranslateTransform { X = newPoint.X - 2D, Y = newPoint.Y - 2D };
     ph.RenderTransform = t;
     cnv.Children.Add(ph);
     //
     TextBlock tb = new TextBlock
     {
         Foreground = new SolidColorBrush(Colors.Gray),
         FontSize = 8
     };
     tb.Text = newPoint.ToString();
     tb.RenderTransform = t;
     cnv.Children.Add(tb);
 }
Exemple #3
0
 static Terrain3D()
 {
     {
     SX = new double[17];
     SZ = new double[17];
     int i = 0;
     for (double d = 0; d < 2; d += 0.125)
     {
       i++;
       SX[i] = Math.Cos(Math.PI * d);
       SZ[i] = Math.Sin(Math.PI * d);
     }
       }
       {
     TEXTURE_COORDINATES = new PointCollection(17);
     TEXTURE_COORDINATES.Add(new Point(0, 0));
     Point p = new Point(1, 0);
     int i = -1;
     while (++i < 16) TEXTURE_COORDINATES.Add(p);
     TEXTURE_COORDINATES.Freeze();
       }
       {
     TRIANGLE_INDICES = new Int32Collection(48);
     for (int i = 1; i < 16; i++)
     {
       TRIANGLE_INDICES.Add(0);
       TRIANGLE_INDICES.Add(i + 1);
       TRIANGLE_INDICES.Add(i);
     }
     TRIANGLE_INDICES.Add(0);
     TRIANGLE_INDICES.Add(1);
     TRIANGLE_INDICES.Add(16);
     TRIANGLE_INDICES.Freeze();
       }
 }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var polygonPoints = new PointCollection();
            if (values.Length == 3 && values[2] is Thickness)
            {
                var width = System.Convert.ToDouble(values[0]);
                var height = System.Convert.ToDouble(values[1]);
                var margin = (Thickness)values[2];

                if (System.Convert.ToInt32(parameter) == 0)
                {
                    polygonPoints.Add(new Point(0 + margin.Left, height - margin.Bottom));
                    polygonPoints.Add(new Point(0, height));
                    polygonPoints.Add(new Point(0, 0));
                    polygonPoints.Add(new Point(width, 0));
                    polygonPoints.Add(new Point(width - margin.Right, 0 + margin.Top));
                }
                else
                {
                    polygonPoints.Add(new Point(0 + margin.Left, height - margin.Bottom));
                    polygonPoints.Add(new Point(0, height));
                    polygonPoints.Add(new Point(width, height));
                    polygonPoints.Add(new Point(width, 0));
                    polygonPoints.Add(new Point(width - margin.Right, 0 + margin.Top));
                }
            }
            return polygonPoints;
        }
        void CreateGeometry()
        {

            double r = Diameter / 2;
            double l = HeadLength * Diameter;

            // arrowhead
            var pc = new PointCollection();
            pc.Add(new Point(-l, r));
            pc.Add(new Point(-l, r * 2));
            pc.Add(new Point(0, 0));

            var headBuilder = new MeshBuilder();
            headBuilder.AddRevolvedGeometry(pc, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), ThetaDiv);
            _head = headBuilder.ToMesh();
            _head.Freeze(); 
            

            // body
            pc = new PointCollection();
            pc.Add(new Point(0, 0));
            pc.Add(new Point(0, r));
            pc.Add(new Point(1, r));

            var bodyBuilder = new MeshBuilder();
            bodyBuilder.AddRevolvedGeometry(pc, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), ThetaDiv);
            _body = bodyBuilder.ToMesh();
            _body.Freeze();
        }
        private static void AddCircleInZCross(MeshBuilder mb, Point3D centre, double radius, int div)
        {
            var points = MeshBuilder.GetCircle(div);

            var vectors = new Point3DCollection();
            var normals = new Vector3DCollection();
            var textures = new PointCollection();

            vectors.Add(new Point3D(centre.X, centre.Y, 0));
            normals.Add(new Vector3D(0, 0, 1));
            textures.Add(new Point(0.5, 0.5));

            for (int i = 0; i < points.Count - 1; i++)
            {
                vectors.Add(new Point3D(points[i].X * radius + centre.X, points[i].Y * radius + centre.Y, centre.Z));
                normals.Add(new Vector3D(0, 0, -1));
                textures.Add(new Point(points[i].X * 0.5 + 0.5, points[i].Y * 0.5 + 0.5));

                vectors.Add(new Point3D(points[i + 1].X * radius + centre.X, points[i + 1].Y * radius + centre.Y, centre.Z));
                normals.Add(new Vector3D(0, 0, 01));
                textures.Add(new Point(points[i + 1].X * 0.5 + 0.5, points[i + 1].Y * 0.5 + 0.5));
            }

            mb.AddTriangleFan(vectors, normals, textures);
        }
        public static MeshGeometry3D CreateRectangle(double height, double width)
        {
            var vertices = new Point3DCollection();
            var normals = new Vector3DCollection();
            var facets = new Int32Collection();
            var textureCoords = new PointCollection();
            vertices.Add(new Point3D(-width / 2, 0, -height / 2));
            vertices.Add(new Point3D(-width / 2, 0, height / 2));
            vertices.Add(new Point3D(width / 2, 0, -height / 2));
            vertices.Add(new Point3D(width / 2, 0, height / 2));

            normals.Add(new Vector3D(0, -1, 0));
            normals.Add(new Vector3D(0, -1, 0));
            normals.Add(new Vector3D(0, -1, 0));
            normals.Add(new Vector3D(0, -1, 0));

            textureCoords.Add(new Point(1,1));
            textureCoords.Add(new Point(1, 0));
            textureCoords.Add(new Point(0,1));
            textureCoords.Add(new Point(0,0));

            facets.Add(0); facets.Add(1); facets.Add(2); facets.Add(3); facets.Add(2); facets.Add(1);
            var rectangle = new MeshGeometry3D();
            rectangle.Positions = vertices;
            rectangle.Normals = normals;
            rectangle.TriangleIndices = facets;
            rectangle.TextureCoordinates = textureCoords;
            return rectangle;
        }
Exemple #8
0
 public LineToolBox()
 {
     InitializeComponent();
     PointCollection points = new PointCollection();
     points.Add(new Point(5, 5));          
     points.Add(new Point(65, 5));
     this.plShadow.Points = points;
     this.ShowMe(points);
 }
Exemple #9
0
 public LineShape()
 {
     InitializeComponent();
     PointCollection points = new PointCollection();
     points.Add(new Point(5, 5));
     points.Add(new Point(65, 5));
     plShadow.Points = points;
     ShowMe(points);
     SetFocus();
 }
Exemple #10
0
		public static PointCollection Normalize(Rect rectangle, double thickness)
		{
			double shift = thickness / 2;
			var pointCollection = new PointCollection();
			pointCollection.Add(new Point(shift, shift));
			pointCollection.Add(new Point(rectangle.Width + shift, shift));
			pointCollection.Add(new Point(rectangle.Width + shift, rectangle.Height + shift));
			pointCollection.Add(new Point(shift, rectangle.Height + shift));
			return pointCollection;
		}
Exemple #11
0
        public static void DrawTile(int x, int y, int tileWidth, int tileHeight, Tile tile)
        {
            var mainWindowInstant = (MainWindow)App.Current.MainWindow;
            Polygon myPolygon = new Polygon();
            myPolygon.Stroke = System.Windows.Media.Brushes.Black;
            myPolygon.Fill = getColor(tile);
            myPolygon.StrokeThickness = 2;
            myPolygon.HorizontalAlignment = HorizontalAlignment.Left;
            myPolygon.VerticalAlignment = VerticalAlignment.Center;


            PointCollection points = new PointCollection();

            Point topCord = getPointTilePoint(x, y, tileWidth, tileHeight);
            points.Add(topCord);
            Point rightCord = getPointTilePoint(x + 1, y, tileWidth, tileHeight);
            points.Add(rightCord);
            Point botCord = getPointTilePoint(x + 1, y + 1, tileWidth, tileHeight);
            points.Add(botCord);
            Point leftCord = getPointTilePoint(x, y + 1, tileWidth, tileHeight);
            points.Add(leftCord);

            myPolygon.Points = points;

            //int screenX = (x - y) * tileWidth / 2 ;
            //int screenY = (x + y) * tileHeight / 2;

            //int pointX;
            //int pointY;

            //Point p = new Point(screenX, screenY);
            //points.Add(p);

            //pointX = screenX + Convert.ToInt32((tileWidth / 2));
            //pointY = Convert.ToInt32(screenY + (tileHeight / 2));

            //p = new Point(pointX, pointY);
            //points.Add(p);

            //pointX = screenX;
            //pointY = screenY + tileHeight;

            //p = new Point(pointX, pointY);
            //points.Add(p);

            //pointX = Convert.ToInt32(screenX - (tileWidth / 2));
            //pointY = Convert.ToInt32(screenY + (tileHeight / 2));

            //p = new Point(pointX, pointY);
            //points.Add(p);

            mainWindowInstant.drawingCanvas.Children.Add(myPolygon);
        }
Exemple #12
0
        /// <summary>
        /// Return a point collection of the specified point in the List of Tuples
        /// and the next point, for a single face of the hexagon
        /// </summary>
        public static PointCollection AsFace(this List<Tuple<double, double>> verticies, int startingPoint)
        {
            var pointCollection = new PointCollection(2);

            var vertex1 = verticies[startingPoint];
            var vertex2 = startingPoint == 5 ? verticies[0] : verticies[startingPoint + 1];

            pointCollection.Add(vertex1.AsPoint());
            pointCollection.Add(vertex2.AsPoint());

            return pointCollection;
        }
        /// <summary>
        /// This method returns a 3D representation of this building walls
        /// </summary>
        /// <param name="nodesDict">List of all the nodes on the map</param>
        /// <param name="map">bounds of the map</param>
        /// <param name="brush">Color of these walls</param>
        /// <returns>ModelUIElement3D of these walls</returns>
        public ModelUIElement3D get3DWalls(Dictionary<long, OsmSharp.Osm.Node> nodesDict, Map map, ImageBrush brush)
        {
            // Surrounding tags of the mesh
            ModelUIElement3D model = new ModelUIElement3D();
            GeometryModel3D geometryModel = new GeometryModel3D();

            // Mesh and his his properties
            MeshGeometry3D mesh = new MeshGeometry3D();
            DiffuseMaterial material = new DiffuseMaterial((System.Windows.Media.Brush)brush);
            Point3DCollection positions = new Point3DCollection();
            PointCollection texturePoints = new PointCollection();
            Int32Collection indices = new Int32Collection();

            // Add Points of surface and with add points of surface with height 0
            positions = getScaledPositionsWall(nodesDict, map);

            // Add indices to the collection
            for (int i = 0; i < positions.Count - 2; i += 2) {
                indices.Add(i);
                indices.Add(i + 2);
                indices.Add(i + 1);
                indices.Add(i + 3);
                indices.Add(i + 1);
                indices.Add(i + 2);

                // Get the width and height of a wall
                float widthWall = (float)Math.Sqrt(Math.Pow(positions[i].X - positions[i + 2].X, 2) + Math.Pow(positions[i].Y - positions[i + 2].Y, 2));
                int imageWidth = (int)(brush.ImageSource.Width * widthWall);
                int imageHeight = (int)(brush.ImageSource.Height * height);

                // Add texture coordinates
                texturePoints.Add(new System.Windows.Point(0, imageHeight));
                texturePoints.Add(new System.Windows.Point(0, 0));
                texturePoints.Add(new System.Windows.Point(imageWidth, imageHeight));
                texturePoints.Add(new System.Windows.Point(imageWidth, 0));
            }

            // Add these collections to the mesh
            mesh.Positions = positions;
            mesh.TriangleIndices = indices;
            mesh.TextureCoordinates = texturePoints;

            // Set the color of front and back of the triangle
            geometryModel.Material = material;
            geometryModel.BackMaterial = material;

            // Add the mesh to the model
            geometryModel.Geometry = mesh;
            model.Model = geometryModel;

            return model;
        }
 private void Button3_Click(object sender, RoutedEventArgs e)
 {
     Window1 wind = new Window1();
      wind.Show();
      PointCollection c = new PointCollection();
      int i = GCDSearch.EuclideanAlgorithm(out time1, Convert.ToInt16(TextBox1_Copy.Text), Convert.ToInt16(TextBox2_Copy.Text));
      int j = GCDSearch.BinaryGCDAlgorithm(out time2, Convert.ToInt16(TextBox1_Copy.Text), Convert.ToInt16(TextBox2_Copy.Text));
      Point v = new Point(time1 * 1000, 1);
      Point z = new Point(time2 * 1000, 2);
      c.Add(v);
      c.Add(z);
      wind.Chart1.DataContext = c;
 }
Exemple #15
0
        public VideoSurface(string mediaSource)
        {
            this.ModelVisual3D = new ModelVisual3D();

            var geometryModel = new GeometryModel3D();
            this.ModelVisual3D.Content = geometryModel;

            this.geometry = new MeshGeometry3D();
            geometryModel.Geometry = geometry;

            var positions = new Point3DCollection();
            positions.Add(new Point3D(0, 0, 0));
            positions.Add(new Point3D(640, 0, 0));
            positions.Add(new Point3D(640, 480, 0));
            positions.Add(new Point3D(0, 480, 0));
            this.geometry.Positions = positions;

            var textureCoordinates = new PointCollection();
            textureCoordinates.Add(new System.Windows.Point(0, 1));
            textureCoordinates.Add(new System.Windows.Point(1, 1));
            textureCoordinates.Add(new System.Windows.Point(1, 0));
            textureCoordinates.Add(new System.Windows.Point(0, 0));
            this.geometry.TextureCoordinates = textureCoordinates;

            var triangleIndices = new Int32Collection();
            triangleIndices.Add(0);
            triangleIndices.Add(1);
            triangleIndices.Add(2);
            triangleIndices.Add(2);
            triangleIndices.Add(3);
            triangleIndices.Add(0);
            this.geometry.TriangleIndices = triangleIndices;

            var material = new EmissiveMaterial();
            var brush = new VisualBrush();
            this.border = new Border();
            this.border.BorderBrush = Brushes.White;
            this.border.BorderThickness = new Thickness(10);
            this.border.Opacity = 0;

            this.mediaElement = new MediaElement();
            mediaElement.LoadedBehavior = MediaState.Manual;
            mediaElement.Source = new Uri(mediaSource);

            this.border.Child = mediaElement;
            brush.Visual = border;
            material.Brush = brush;
            geometryModel.Material = material;

            this.mediaElement.MediaEnded += new RoutedEventHandler(mediaElement_MediaEnded);
        }
        private Polyline CreateAPolyline(double x1, double y1, double x2, double y2)
        {
            var arrow = new Polyline();
            arrow.Stroke = FindResource("BasicFontColorBrush") as SolidColorBrush;
            arrow.StrokeThickness = 0.5;

            var polygonPoints = new PointCollection();
            polygonPoints.Add(new Point(x1, y1));
            polygonPoints.Add(new Point(x2, y2));

            arrow.Points = polygonPoints;

            return arrow;
        }
Exemple #17
0
		public PointCollection GenerateTextures() {
			PointCollection points=new PointCollection();
			System.Windows.Point point;
			for(int i=0;i<VertexNormals.Count;i++) {
				if(VertexNormals[i].Texture==null) {
					points.Add(new System.Windows.Point(0,0));
				}
				else {
					point=new System.Windows.Point(VertexNormals[i].Texture.X,VertexNormals[i].Texture.Y);
					points.Add(point);
				}
			}
			return points;
		}
        private void drawModifiedHistogram(byte[] pixelData)
        {
            BGRAarray bgraArray = splitColor(pixelData);
            int[] blueArray = bgraArray.blueArray;
            int[] greenArray = bgraArray.greenArray;
            int[] redArray = bgraArray.redArray;
            int[] alphaArray = bgraArray.alphaArray;

            PointCollection bluePoints = new PointCollection();
            PointCollection greenPoints = new PointCollection();
            PointCollection redPoints = new PointCollection();
            PointCollection alphaPoints = new PointCollection();

            Point p = new Point();

            double blueArrayMax = (double)blueArray.Max();
            double greenArrayMax = (double)greenArray.Max();
            double redArrayMax = (double)redArray.Max();
            double alphaArrayMax = (double)alphaArray.Max();

            p.X = (double)(0);
            p.Y = (double)(ModifiedBlueHistogram.Height * (1 - blueArray[0] / blueArrayMax));
            bluePoints.Add(p);
            p.Y = (double)(ModifiedGreenHistogram.Height * (1 - greenArray[0] / greenArrayMax));
            greenPoints.Add(p);
            p.Y = (double)(ModifiedRedHistogram.Height * (1 - redArray[0] / redArrayMax));
            redPoints.Add(p);
            p.Y = (double)(ModifiedAlphaHistogram.Height * (1 - alphaArray[0] / alphaArrayMax));
            alphaPoints.Add(p);

            for (int i = 0; i < 256; i++)
            {
                p.X = (double)(i);
                p.Y = (double)(ModifiedBlueHistogram.Height * (1 - blueArray[i] / blueArrayMax));
                bluePoints.Add(p);
                p.Y = (double)(ModifiedGreenHistogram.Height * (1 - greenArray[i] / greenArrayMax));
                greenPoints.Add(p);
                p.Y = (double)(ModifiedRedHistogram.Height * (1 - redArray[i] / redArrayMax));
                redPoints.Add(p);
                p.Y = (double)(ModifiedAlphaHistogram.Height * (1 - alphaArray[i] / alphaArrayMax));
                alphaPoints.Add(p);
            }

            ModifiedBlueHistogram.Points = bluePoints;
            ModifiedGreenHistogram.Points = greenPoints;
            ModifiedRedHistogram.Points = redPoints;
            ModifiedAlphaHistogram.Points = alphaPoints;
        }
        private void tekenLijn()
        {
            //Polyline aanmaken
            Polyline line = new Polyline();
            line.Stroke = Brushes.Aquamarine;
            line.Visibility = Visibility.Visible;
            line.StrokeThickness = 3;

            //Punten
            PointCollection punten = new PointCollection();

            //Dingen die in de formule ingevuld gaan worden
            double a = 100;// canvas.Height / 2; //De evenwichtsstand
            double b = 2;// canvas.Height / 4; //De amplitude
            //double d = Convert.ToDouble(ActualHeightProperty.ToString()) ; //de x-coördinaat van een punt waar de grafiek stijgend de evenwichtsstand snijdt

            double windowbreedte = canvas.ActualWidth;
            double windowhoogte = canvas.ActualHeight/2;

            //Alle punten overlopen
            for (int i = 0; i < windowbreedte; i++)
            {
                //punten.Add(new Point() { X = i, Y = windowhoogte * (1 - Math.Sin(i * (Math.PI / (windowbreedte/6))))});
                punten.Add(new Point(i,  Math.Sin(((2*Math.PI )/ b) * (i - windowbreedte)) * windowhoogte));
                //2,5 + 2,5 sin(2π / 9(x – 3))

            }

            line.Points = punten;

            //Lijn tekenen
            canvas.Children.Add(line);

        }
Exemple #20
0
        /// <summary>
        /// Calculates the points for back face
        /// </summary>
        public void CalculateBackFacePoints()
        {
            _backFacePoints = new PointCollection();

            foreach(Point point in _frontFacePoints)
                _backFacePoints.Add(new Point(point.X + _depth3D, point.Y - _depth3D));
        }
Exemple #21
0
        private void drawShape(bool success, List<DataPoint> points)
        {
            lnPoints.Points.Clear();

            if (success)
            {
                PointCollection pointCollection = new PointCollection();
                for (int x = 0; x < points.Count; x++)
                {
                    DataPoint point = points[x];
                    pointCollection.Add(point.UiPoint);
                }

                lnPoints.Points = pointCollection;
                message.Text = "Success";
                message.Foreground = Brushes.LightGreen;
                message.FontWeight = FontWeights.Normal;
            }
            else
            {
                message.Text = "Failure";
                message.Foreground = Brushes.Red;
                message.FontWeight = FontWeights.Bold;
            }
        }
        protected override void Triangulate(DependencyPropertyChangedEventArgs args, 
                                            Point3DCollection vertices, 
                                            Vector3DCollection normals, 
                                            Int32Collection indices, 
                                            PointCollection textures)
        {
            vertices.Clear();
            normals.Clear();
            indices.Clear();
            textures.Clear();

            MeshGeometry3D mesh = MeshGenerator.Geometry;

            foreach (Point3D vertex in mesh.Positions)
                vertices.Add(vertex);

            foreach (Vector3D normal in mesh.Normals)
                normals.Add(normal);

            foreach (int index in mesh.TriangleIndices)
                indices.Add(index);

            foreach (Point texture in mesh.TextureCoordinates)
                textures.Add(texture);
        }
		protected override void Resize(ResizeDirection direction, Vector vector)
		{
			ElementBaseShape element = DesignerItem.Element as ElementBaseShape;
			if (element != null)
			{
				var rect = element.GetRectangle();
				var placeholder = new Rect(rect.TopLeft, rect.Size);
				if ((direction & ResizeDirection.Top) == ResizeDirection.Top)
				{
					placeholder.Y += vector.Y;
					placeholder.Height -= vector.Y;
				}
				else if ((direction & ResizeDirection.Bottom) == ResizeDirection.Bottom)
					placeholder.Height += vector.Y;
				if ((direction & ResizeDirection.Left) == ResizeDirection.Left)
				{
					placeholder.X += vector.X;
					placeholder.Width -= vector.X;
				}
				else if ((direction & ResizeDirection.Right) == ResizeDirection.Right)
					placeholder.Width += vector.X;
				double kx = rect.Width == 0 ? 0 : placeholder.Width / rect.Width;
				double ky = rect.Height == 0 ? 0 : placeholder.Height / rect.Height;

				_points = new PointCollection();
				foreach (var point in element.Points)
					_points.Add(new Point(placeholder.X + kx * (point.X - rect.X), placeholder.Y + ky * (point.Y - rect.Y)));
				element.Points = _points;

				DesignerItem.RefreshPainter();
				DesignerCanvas.DesignerChanged();
			}
		}
        private void goButton_Click(object sender, RoutedEventArgs e)
        {
            Parser.Parser.Variable variableI;
            Parser.Parser parser = new Parser.Parser();

            parser = new Parser.Parser();
            parser.InputString = functionTextBox.Text;
            variableI = parser.GetVariable("x");

            PointCollection p = new PointCollection();

            Random r = new Random();

            for (float i = 0; i <= 10; i += 0.5f)
            {
                points.pointX.Add(i);
                variableI.value = i;
                clearSignal.Add(variableI.value);

                //variableI.value = (i % 3 == 0) ? i * (float)r.NextDouble() : i;
                //noiseSignal.Add(variableI.value);
                points.pointY.Add(parser.Calculate());
                p.Add(new Point(parser.Calculate(), i));
            }

            chart.DataContext = p;
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var rc = value as IEnumerable<RegisterTransaction>;
            if (rc == null || rc.Count() == 0)
                return null;

            // Cheat a little here and get the min/max ranges for scaling
            double minValue = rc.Min(rt => rt.TotalBalance);
            double maxValue = rc.Max(rt => rt.TotalBalance);
            double increment = 100.0 / rc.Count();

            maxValue = Math.Max(Math.Abs(minValue), Math.Abs(maxValue));
            minValue = -maxValue;

            var pc = new PointCollection();
            double x = 0;
            foreach (var reg in rc)
            {
                double yPos = ((-minValue + reg.TotalBalance)/(maxValue - minValue)) * 100; 
                pc.Add(new Point(x, yPos));
                x += increment;
            }

            return pc;
        }
        protected PointCollection GetPoints(Rect bounds)
        {
            // Inscribe the shape inside a circle
            double angle = -(Math.PI / 2.0f);
            double deltaAngle = (Math.PI * 2) / Sides;

            double halfWidth = bounds.Width / 2;
            double halfHeight = bounds.Height / 2;

            PointCollection points = new PointCollection(Sides);
            for (int i = 0; i < this.Sides; i++)
            {
                // Convert from polar to cartesian coordinates.
                double x = halfWidth * Math.Cos(angle);
                double y = halfHeight * Math.Sin(angle);

                points.Add(new Point(
                    x + halfWidth + bounds.Left,
                    y + halfHeight + bounds.Top));

                angle += deltaAngle;
            }

            return points;
        }
Exemple #27
0
        /// <summary>
        /// Return a point collection of the specified point in the List of Tuples
        /// and the next point and the derived center point, for a single sextant of the hexagon
        /// </summary>
        public static PointCollection AsSextant(this List<Tuple<double, double>> verticies, int startingPoint)
        {
            var pointCollection = new PointCollection(3);

            var centerX = verticies.Average(v => v.Item1);
            var centerY = verticies.Average(v => v.Item2);

            var vertex1 = verticies[startingPoint];
            var vertex2 = startingPoint == 5 ? verticies[0] : verticies[startingPoint + 1];

            pointCollection.Add(new Point(centerX, centerY));
            pointCollection.Add(vertex1.AsPoint());
            pointCollection.Add(vertex2.AsPoint());

            return pointCollection;
        }
        void CreateGeometry()
        {

            double r = Diameter / 2;

            var pc = new PointCollection();
            pc.Add(new Point(0, 0));
            pc.Add(new Point(0, r));
            pc.Add(new Point(1, r));
            pc.Add(new Point(1, 0));

            var builder = new MeshBuilder();
            builder.AddRevolvedGeometry(pc, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), ThetaDiv);
            _tube= builder.ToMesh();
            _tube.Freeze();
        }
        public Computing()
        {
            Result = new Moment(0);
            //Tmr = new Timer(3000);
            //Tmr.AutoReset = true;
            //Tmr.Elapsed += Tmr_Elapsed;

            InpFileName = @"D:\ballistics\ballisticwpf\config.txt";
            OutFileName = @"D:\ballistics\ballisticwpf\result.txt";

            //string InpFileName = @"C:\Users\Andrey\Documents\Visual Studio 2015\Projects\ballistics\ballisticwpf\config.txt";
            //string OutFileName = @"C:\Users\Andrey\Documents\Visual Studio 2015\Projects\ballistics\ballisticwpf\result.txt";
            Config = new Configuration(0);
            Config.ReadConfugurationFromFile(InpFileName);

            bool ExistFlag = File.Exists(OutFileName);
            if (ExistFlag)
            {
                File.Delete(OutFileName);
            }

            Positions = new PointCollection();
            Positions.Add(new Point(0, 0));

            Chart = new Polyline();
            Chart.Points = Positions;

            //BgrWork = ((BackgroundWorker)this.FindResource("bgrWork"));
            //ComplexArg = new ComplexForAsyns(Config);
        }
Exemple #30
0
        /// <summary>
        /// Calculates the texture for the specified model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="mesh">
        /// The mesh.
        /// </param>
        public override void Calculate(TerrainModel model, MeshGeometry3D mesh)
        {
            var normals = MeshGeometryHelper.CalculateNormals(mesh);
            var texcoords = new PointCollection();
            var up = new Vector3D(0, 0, 1);
            for (int i = 0; i < normals.Count; i++)
            {
                double slope = Math.Acos(Vector3D.DotProduct(normals[i], up)) * 180 / Math.PI;
                double u = slope / 40;
                if (u > 1)
                {
                    u = 1;
                }

                if (u < 0)
                {
                    u = 0;
                }

                texcoords.Add(new Point(u, u));
            }

            this.TextureCoordinates = texcoords;
            this.Material = MaterialHelper.CreateMaterial(this.Brush);
        }
Exemple #31
0
        protected override System.Windows.Shapes.Shape createShape()
        {
            var pc = new media.PointCollection();

            pc.Add(bases[0]);
            pc.Add(bases[1]);
            pc.Add(bases[2]);

            return(new wpf2d.Polyline()
            {
                Name = MakeCtrlId(),
                HorizontalAlignment = wpf.HorizontalAlignment.Left,
                VerticalAlignment = wpf.VerticalAlignment.Top,
                Stroke = media.Brushes.Black,
                StrokeThickness = 5,
                Points = pc
            });
        }
Exemple #32
0
            internal unsafe void AddFigureToList(bool isFilled, bool isClosed, MilPoint2F *pPoints, UInt32 pointCount, byte *pSegTypes, UInt32 segmentCount)
            {
                if (pointCount >= 1 && segmentCount >= 1)
                {
                    PathFigure figure = new PathFigure();

                    figure.IsFilled   = isFilled;
                    figure.StartPoint = new Point(pPoints->X, pPoints->Y);

                    int pointIndex   = 1;
                    int sameSegCount = 0;

                    for (int segIndex = 0; segIndex < segmentCount; segIndex += sameSegCount)
                    {
                        byte segType = (byte)(pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegTypeMask);

                        sameSegCount = 1;

                        // Look for a run of same-type segments for a PolyXXXSegment.
                        while (((segIndex + sameSegCount) < segmentCount) &&
                               (pSegTypes[segIndex] == pSegTypes[segIndex + sameSegCount]))
                        {
                            sameSegCount++;
                        }

                        bool fStroked = (pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegIsAGap) == (byte)0;
                        bool fSmooth  = (pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegSmoothJoin) != (byte)0;

                        if (segType == (byte)MILCoreSegFlags.SegTypeLine)
                        {
                            if (pointIndex + sameSegCount > pointCount)
                            {
                                throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                            }

                            if (sameSegCount > 1)
                            {
                                PointCollection ptCollection = new PointCollection();
                                for (int i = 0; i < sameSegCount; i++)
                                {
                                    ptCollection.Add(new Point(pPoints[pointIndex + i].X, pPoints[pointIndex + i].Y));
                                }
                                ptCollection.Freeze();

                                PolyLineSegment polySeg = new PolyLineSegment(ptCollection, fStroked, fSmooth);
                                polySeg.Freeze();

                                figure.Segments.Add(polySeg);
                            }
                            else
                            {
                                Debug.Assert(sameSegCount == 1);
                                figure.Segments.Add(new LineSegment(new Point(pPoints[pointIndex].X, pPoints[pointIndex].Y), fStroked, fSmooth));
                            }

                            pointIndex += sameSegCount;
                        }
                        else if (segType == (byte)MILCoreSegFlags.SegTypeBezier)
                        {
                            int pointBezierCount = sameSegCount * 3;

                            if (pointIndex + pointBezierCount > pointCount)
                            {
                                throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                            }

                            if (sameSegCount > 1)
                            {
                                PointCollection ptCollection = new PointCollection();
                                for (int i = 0; i < pointBezierCount; i++)
                                {
                                    ptCollection.Add(new Point(pPoints[pointIndex + i].X, pPoints[pointIndex + i].Y));
                                }
                                ptCollection.Freeze();

                                PolyBezierSegment polySeg = new PolyBezierSegment(ptCollection, fStroked, fSmooth);
                                polySeg.Freeze();

                                figure.Segments.Add(polySeg);
                            }
                            else
                            {
                                Debug.Assert(sameSegCount == 1);

                                figure.Segments.Add(new BezierSegment(
                                                        new Point(pPoints[pointIndex].X, pPoints[pointIndex].Y),
                                                        new Point(pPoints[pointIndex + 1].X, pPoints[pointIndex + 1].Y),
                                                        new Point(pPoints[pointIndex + 2].X, pPoints[pointIndex + 2].Y),
                                                        fStroked,
                                                        fSmooth));
                            }

                            pointIndex += pointBezierCount;
                        }
                        else
                        {
                            throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                        }
                    }

                    if (isClosed)
                    {
                        figure.IsClosed = true;
                    }

                    figure.Freeze();
                    Figures.Add(figure);

                    // Do not bother adding empty figures.
                }
            }