//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); }
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, int b) { MPoint newp = new MPoint(a.X + b, a.Y + b); return(newp); }
public static MPoint operator *(MPoint a, double b) { MPoint newp = new MPoint(a.X * b, a.Y * b); return(newp); }
public static MPoint operator -(MPoint a, double b) { MPoint newp = new MPoint(a.X - b, a.Y - b); return(newp); }
public static MPoint operator -(MPoint a, MPoint b) { MPoint newp = new MPoint(a.X - b.X, a.Y - b.Y); 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); }