pakvur.blogg.se

Hexagon data
Hexagon data




hexagon data

Private Point CalculateHarmonicPolygon(int Corners, Point Center, double InnerCircleRadius)ĭouble LineWidth = (2 * Math.Tan(Math.PI / Corners)) * InnerCircleRadius ĭouble ptY = ((pt1X - Center.X) * Math.Sin(i)) + ((pt1Y - Center.Y) * Math.Cos(i)) + Center. Private Point CalculateHarmonicPolygon(Point Center, double OuterCircleRadius, int Corners) Private Point CalculateHarmonicPolygon(int Corners, double LineWidth, Point Center)ĭouble rU = LineWidth / (2 * Math.Sin(Math.PI / Corners)) ĭouble ptX = ((pt1X - Center.X) * Math.Cos(i)) + ((pt1Y - Center.Y) * -Math.Sin(i)) + Center.X ĭouble ptY = ((pt1X - Center.X) * Math.Sin(i)) + ((pt1Y - Center.Y) * Math.Cos(i)) + Center.Y Path1.Stroke = new SolidColorBrush(Colors.Blue) P.Figures.Add(new PathFigure(((PolyLineSegment)ps).Points, psc, true)) PathSegmentCollection psc = new PathSegmentCollection() PathSegment ps = new PolyLineSegment(CalculateHarmonicPolygon(6, 100, new Point(this.Width / 2, this.Height / 2)), true) Here's some methods of an old WinForm application from me to create harmonic polygons (updated types for wpf (basically floats to doubles :-) )): private void UserControl_Loaded(object sender, RoutedEventArgs e)

hexagon data

Segment.Point = new Point(x + 0.5 * hexagon.StrokeThickness, Private void AddPoint(double x, double y)

hexagon data

PathGeometry geometry = new PathGeometry() įigure.StartPoint = new Point(0.25 * width, 0) Private void CreateDataPath(double width, double height) Private void hexagon_Loaded(object sender, RoutedEventArgs e)ĬreateDataPath(hexagon.Width, hexagon.Height) You could for example handle the Loaded event of the Path like this: public partial class MainWindow : Window You better create the hexagon programmatically as described here: Each edge keeps track of its two adjoining hexes, and each vertex keeps track of its three adjoining hexes (hexes on the edges of the map will be a special case).






Hexagon data