private void SetLayerCoordinates(Layer currentLayer, int NodesPerParent, int TotalNodes, double Distance) { double d_angle = MapMath.FindDiffAngle(TotalNodes); double rad = 0; rad = MapMath.FindArcRadius(d_angle, Distance); MPoint currentPoint = null; PageNode parent = null; int i = 0; foreach (PageNode pn in currentLayer.Links) { if (parent != pn.Parent) { parent = pn.Parent; currentPoint = GetInitialPoint(parent, NodesPerParent, d_angle, rad, ref i); } else { currentPoint = MapMath.TransformPoint(-1 * d_angle, currentPoint); } pn.Position = currentPoint; pn.Index = i++; } MapMath.MINRAD = rad; }
public PageNode(Page Page, PageNode Parent) { m_Page = Page; m_parent = Parent; m_size = 0; m_position = new MPoint(0, 0); m_font = new Font("Calibri", 12, FontStyle.Regular); }
public MPoint GetInitialPoint(PageNode Parent, int NodesPerParent, double angle, double Rad, ref int MyIndex) { MPoint point1 = new MPoint(0, Rad); MyIndex = NodesPerParent * Parent.Index; //for (int i = 0; i < MyIndex; i++ ) point1 = MapMath.TransformPoint(-1 * MyIndex * angle, point1); return(point1); }
//double d = Mindistance / 2; //double r1 = Math.Sqrt(Math.Pow(Parent.X, 2) + Math.Pow(Parent.Y, 2)); ////double pr1 = Math.Sqrt(Math.Pow(r1, 2) - Math.Pow(d, 2)); ////double pr2 = LongRadius - pr1; ////double r3 = Math.Sqrt(Math.Pow(d, 2) + Math.Pow(pr2, 2)); ////double newx = Math.Sqrt((Math.Pow(LongRadius, 2) + Math.Pow(r3, 2)) / 2); ////double newy = Math.Sqrt(Math.Pow(LongRadius, 2) - Math.Pow(newx, 2)); ////MPoint newPoint = new MPoint(newx, newy); ////return newPoint; //double angleD = -1 * Math.Asin(GetRadian(d / r1)); //double ratio = LongRadius / r1; //MPoint newpoint = TransformPoint(angleD, Parent); //double m = FindGradient(newpoint, new MPoint(0, 0)); //double c = FindLineCut(new MPoint(0, 0), m); //double newy = ratio* (m * newpoint.X + c); //double newx = (newy / m) - c; //newpoint = new MPoint(newx, newy); //return newpoint; public static MPoint TransformPoint(double angle, MPoint p) { double cosTheta = Math.Cos(angle); double sinTheta = Math.Sin(angle); double x = p.X * cosTheta + p.Y * sinTheta; double y = p.Y * cosTheta - p.X * sinTheta; return(new MPoint(Math.Round(x, 7), Math.Round(y, 7))); }
public static double FindGradient(MPoint point1, MPoint point2) { if (point2.X == point1.X) { return(double.PositiveInfinity); } double gradient = (point1.Y - point2.Y) / (point1.X - point2.X); return(gradient); }
private void DrawLine(MPoint pos1, MPoint pos2, ref Bitmap bmp) { try { Graphics g = Graphics.FromImage(bmp); Pen p1 = new Pen(Color.Red); g.DrawLine(p1, pos1.Point(), pos2.Point()); } catch { } }
private void SetDot(string Text, MPoint pos, ref Bitmap bmp) { try { Graphics g = Graphics.FromImage(bmp); Font mf = new Font("Calibri", 12, FontStyle.Regular); int height = mf.Height; SizeF s = g.MeasureString(Text, mf); g.DrawRectangle(Pens.Black, pos.iX - (int)(s.Width / 2), pos.iY - s.Height / 2, s.Width + 2, s.Height + 1); g.FillRectangle(Brushes.White, pos.iX - (int)(s.Width / 2) + 1, pos.iY - ((s.Height) / 2) + 1, s.Width, s.Height); g.DrawString(Text, new Font("Calibri", 12, FontStyle.Regular), Brushes.Black, new PointF(pos.iX - (int)(s.Width / 2), pos.iY - s.Height / 2)); } catch { } }
public void SetDot(MPoint Origin, ref Bitmap bmp) { try { Graphics g = Graphics.FromImage(bmp); SizeF s = StringSize(g); MPoint pos = m_position + Origin - new MPoint(s.Width / 2, (s.Height) / 2); g.DrawRectangle(Pens.Black, pos.iX, pos.iY, s.Width + 2, s.Height + 1); pos += 1; g.FillRectangle(Brushes.White, pos.iX, pos.iY, s.Width, s.Height); pos -= 1; g.DrawString(m_Page.Title, m_font, Brushes.Black, pos.PointF()); } catch { } }
private void DrawCircle(double rad, MPoint midp, ref Bitmap bmp) { //Start at Xm and draw up to Xm + R for (int x = 0; x <= rad; x++) { int y = (int)Math.Floor(Math.Sqrt(Math.Pow(Convert.ToDouble(rad), 2) - Math.Pow(x, 2))); SetPixel(midp.iX + x, midp.iY + y, ref bmp); SetPixel(midp.iX + x, midp.iY - y, ref bmp); SetPixel(midp.iX - x, midp.iY + y, ref bmp); SetPixel(midp.iX - x, midp.iY - y, ref bmp); SetPixel(midp.iX + y, midp.iY + x, ref bmp); SetPixel(midp.iX + y, midp.iY - x, ref bmp); SetPixel(midp.iX - y, midp.iY + x, ref bmp); SetPixel(midp.iX - y, midp.iY - x, ref bmp); } }
public override bool Equals(object obj) { // If both are null, or both are same instance, return true. if (System.Object.ReferenceEquals(this, obj)) { return(true); } // If one is null, but not both, return false. if (((object)this == null) || ((object)obj == null)) { return(false); } if (obj.GetType() == typeof(MPoint)) { MPoint b = (MPoint)obj; // Return true if the fields match: return((m_x == b.X && m_y == b.Y) || (iX == b.iX && iY == b.iY)); } return(false); }
public static MPoint operator -(MPoint a, MPoint b) { MPoint newp = new MPoint(a.X - b.X, a.Y - b.Y); return(newp); }
public static MPoint operator *(MPoint a, double b) { MPoint newp = new MPoint(a.X * b, a.Y * b); return(newp); }
public static double FindLineCut(MPoint point, double Gradient) { double c = point.Y - Gradient * point.X; return(c); }
public static double FindLineLength(MPoint point1, MPoint point2) { double distance = Math.Sqrt(Math.Pow(point1.X - point2.X, 2) + Math.Pow(point1.Y - point2.Y, 2)); return(distance); }
public static MPoint operator +(MPoint a, int b) { MPoint newp = new MPoint(a.X + b, a.Y + b); return(newp); }
public ImageGenerator(int Width, int Height, MPoint Origin) { m_height = Height; m_width = Width; m_origin = Origin; }
private void SetDot(int x, int y, ref Bitmap bmp, int size) { MPoint mid = new MPoint(x, y); DrawCircle(size, mid, ref bmp); }
public static MPoint operator -(MPoint a, double b) { MPoint newp = new MPoint(a.X - b, a.Y - b); return(newp); }