//***************************************************************************
        // Static Methods
        //
        public static PointF PointAtAngle(CircleF cir, float degree)
        {
            if (degree > 360 || degree < 0)
            {
                throw new ArgumentOutOfRangeException("degree", degree, "Valid values for 'degree' are 0 through 360 in floating point increments");
            }

            // For the Law of Cosines to work, we have to convert degrees
            //   into radians.
            double t      = degree / 180 * System.Math.PI;
            PointF retVal = new PointF(
                (float)(cir.Center.X + cir.Radius + System.Math.Sin(t)),
                (float)(cir.Center.Y + cir.Radius + System.Math.Cos(t)));

            return(retVal);

            //for (float t = 0; t < degree; t+=0.1)
            //{
            //    double a = t * 180 / Math.PI;
            //    retVal.X = (float)(cir.Center.X + cir.Radius + Math.Sin(a));
            //    retVal.Y = (flaot)(cir.Center.Y + cir.Radius + Math.Cos(a));
            //}
        }
        public static float AreaOfIntersect(CircleF val1, CircleF val2)
        {
            // First, we find the distance between the two circle's centers.
            double c = LineF.FindDistance(val1.Center, val2.Center);
            // Then, we use the Law of Cosines to find the angle of the points
            //   at which the two cirlces touch from the circles' centers.
            //  cos(theta) = (r2^2 + c^2 - r1^2) / (2 * r1 * c)
            double theta = System.Math.Sin((System.Math.Pow(val2.Radius, 2) + System.Math.Pow(c, 2) - System.Math.Pow(val1.Radius, 2)) / (2 * val2.Radius * c));

            // Now we find the distance from the midpoint of the chord (the line
            //   segment drawn between the two intersection points) to the center
            //   of either circle.  This value will always be the same no matter
            //   which circle you calculate to.
            double d = val1.Radius * System.Math.Cos(theta / 2);

            // Now, the each 'segment' can be seen as two triangles back-to-back
            //   with an arched cap.  This arched cap is the area of intersect.
            //  (r1^2 * arccos(d / r1)) - (d * sqrt(r1^2 - d^2))
            double area = (System.Math.Pow(val1.Radius, 2) * System.Math.Acos(d / val1.Radius)) - (d * System.Math.Sqrt(System.Math.Pow(val1.Radius, 2) - System.Math.Pow(d, 2)));

            // Since the area of intersect is two of these arched caps back-to-back,
            //   the total area of intersect is twice "area".
            return((float)(area * 2));
        }
Beispiel #3
0
 public static Circle Floor(CircleF val)
 { return new Circle((int)System.Math.Floor(val.Center.X), (int)System.Math.Floor(val.Center.Y), (int)System.Math.Floor(val.Radius)); }
Beispiel #4
0
 //***************************************************************************
 // Static Methods
 // 
 public static Circle Truncate(CircleF val)
 { return new Circle((int)System.Math.Truncate(val.Center.X), (int)System.Math.Truncate(val.Center.Y), (int)System.Math.Truncate(val.Radius)); }
 public int AreaOfIntersect(Circle cir)
 {
     return((int)System.Math.Truncate(CircleF.AreaOfIntersect(CircleF.FromCircle(this), CircleF.FromCircle(cir))));
 }
 public static Circle Round(CircleF val)
 {
     return(new Circle((int)System.Math.Round(val.Center.X), (int)System.Math.Round(val.Center.Y), (int)System.Math.Round(val.Radius)));
 }
Beispiel #7
0
 public static void DrawShape(CircleF cir, Graphics g, Pen p)
 {
     using (GraphicsPath path = cir.GetShape(30, PathPointType.Line))
         g.DrawPath(p, path);
 }
Beispiel #8
0
 public static float AngleOfPoint(CircleF cir, PointF point)
 {
     return LineF.FindAngle(cir.Center, new PointF(cir.Center.X + cir.Radius, cir.Center.Y), cir.Center, point);
 }
Beispiel #9
0
        //***************************************************************************
        // Static Methods
        // 
        public static PointF PointAtAngle(CircleF cir, float degree)
        {
            if (degree > 360 || degree < 0)
                throw new ArgumentOutOfRangeException("degree", degree, "Valid values for 'degree' are 0 through 360 in floating point increments");

            // For the Law of Cosines to work, we have to convert degrees
            //   into radians.
            double t = degree / 180 * System.Math.PI;
            PointF retVal = new PointF(
                (float)(cir.Center.X + cir.Radius + System.Math.Sin(t)),
                (float)(cir.Center.Y + cir.Radius + System.Math.Cos(t)));

            return retVal;

            //for (float t = 0; t < degree; t+=0.1)
            //{
            //    double a = t * 180 / Math.PI;
            //    retVal.X = (float)(cir.Center.X + cir.Radius + Math.Sin(a));
            //    retVal.Y = (flaot)(cir.Center.Y + cir.Radius + Math.Cos(a));
            //}
        }
Beispiel #10
0
 public static float AngleOfPoint(CircleF cir, PointF point)
 {
     return(LineF.FindAngle(cir.Center, new PointF(cir.Center.X + cir.Radius, cir.Center.Y), cir.Center, point));
 }
Beispiel #11
0
 public static float AngleOfPoint(CircleF cir, float x, float y)
 {
     return(AngleOfPoint(cir, new PointF(x, y)));
 }
Beispiel #12
0
 public float AreaOfIntersect(CircleF circle)
 {
     return(CircleF.AreaOfIntersect(this, circle));
 }
Beispiel #13
0
 public float AngleOfPoint(PointF point)
 {
     return(CircleF.AngleOfPoint(this, point));
 }
Beispiel #14
0
 public static Circle Ceiling(CircleF val)
 {
     return(new Circle((int)System.Math.Ceiling(val.Center.X), (int)System.Math.Ceiling(val.Center.Y), (int)System.Math.Ceiling(val.Radius)));
 }
Beispiel #15
0
 public static Circle Ceiling(CircleF val)
 { return new Circle((int)System.Math.Ceiling(val.Center.X), (int)System.Math.Ceiling(val.Center.Y), (int)System.Math.Ceiling(val.Radius)); }
Beispiel #16
0
 public static void DrawShape(CircleF cir, Graphics g, Pen p)
 {
     using (GraphicsPath path = cir.GetShape(30, PathPointType.Line))
         g.DrawPath(p, path);
 }
Beispiel #17
0
 public float AreaOfIntersect(CircleF circle)
 { return CircleF.AreaOfIntersect(this, circle); }
Beispiel #18
0
 public static void FillShape(CircleF cir, Graphics g, Brush b)
 {
     using (GraphicsPath path = cir.GetShape(60, PathPointType.Bezier))
         g.FillPath(b, path);
 }
Beispiel #19
0
 public static float AngleOfPoint(CircleF cir, float x, float y)
 {
     return AngleOfPoint(cir, new PointF(x, y));
 }
Beispiel #20
0
 public Point GetPointAtAngle(float degree)
 {
     return(Point.Truncate(CircleF.PointAtAngle(CircleF.FromCircle(this), degree)));
 }
Beispiel #21
0
        public static float AreaOfIntersect(CircleF val1, CircleF val2)
        {
            // First, we find the distance between the two circle's centers.
            double c = LineF.FindDistance(val1.Center, val2.Center);
            // Then, we use the Law of Cosines to find the angle of the points
            //   at which the two cirlces touch from the circles' centers.
            //  cos(theta) = (r2^2 + c^2 - r1^2) / (2 * r1 * c)
            double theta = System.Math.Sin((System.Math.Pow(val2.Radius, 2) + System.Math.Pow(c, 2) - System.Math.Pow(val1.Radius, 2)) / (2 * val2.Radius * c));

            // Now we find the distance from the midpoint of the chord (the line
            //   segment drawn between the two intersection points) to the center
            //   of either circle.  This value will always be the same no matter
            //   which circle you calculate to.
            double d = val1.Radius * System.Math.Cos(theta / 2);

            // Now, the each 'segment' can be seen as two triangles back-to-back
            //   with an arched cap.  This arched cap is the area of intersect.
            //  (r1^2 * arccos(d / r1)) - (d * sqrt(r1^2 - d^2))
            double area = (System.Math.Pow(val1.Radius, 2) * System.Math.Acos(d / val1.Radius)) - (d * System.Math.Sqrt(System.Math.Pow(val1.Radius, 2) - System.Math.Pow(d, 2)));

            // Since the area of intersect is two of these arched caps back-to-back,
            //   the total area of intersect is twice "area".
            return (float)(area * 2);
        }
Beispiel #22
0
 public int AngleOfPoint(Point point)
 {
     return((int)System.Math.Truncate(CircleF.AngleOfPoint(CircleF.FromCircle(this), new PointF((float)point.X, (float)point.Y))));
 }
Beispiel #23
0
 public static void FillShape(CircleF cir, Graphics g, Brush b)
 {
     using (GraphicsPath path = cir.GetShape(60, PathPointType.Bezier))
         g.FillPath(b, path);
 }
Beispiel #24
0
 //***************************************************************************
 // Static Methods
 //
 public static Circle Truncate(CircleF val)
 {
     return(new Circle((int)System.Math.Truncate(val.Center.X), (int)System.Math.Truncate(val.Center.Y), (int)System.Math.Truncate(val.Radius)));
 }