예제 #1
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));
            //}
        }
예제 #2
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));
        }
예제 #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)); }
예제 #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)); }
예제 #5
0
 public int AreaOfIntersect(Circle cir)
 {
     return((int)System.Math.Truncate(CircleF.AreaOfIntersect(CircleF.FromCircle(this), CircleF.FromCircle(cir))));
 }
예제 #6
0
 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)));
 }
예제 #7
0
 public static void DrawShape(CircleF cir, Graphics g, Pen p)
 {
     using (GraphicsPath path = cir.GetShape(30, PathPointType.Line))
         g.DrawPath(p, path);
 }
예제 #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);
 }
예제 #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));
            //}
        }
예제 #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));
 }
예제 #11
0
 public static float AngleOfPoint(CircleF cir, float x, float y)
 {
     return(AngleOfPoint(cir, new PointF(x, y)));
 }
예제 #12
0
 public float AreaOfIntersect(CircleF circle)
 {
     return(CircleF.AreaOfIntersect(this, circle));
 }
예제 #13
0
 public float AngleOfPoint(PointF point)
 {
     return(CircleF.AngleOfPoint(this, point));
 }
예제 #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)));
 }
예제 #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)); }
예제 #16
0
 public static void DrawShape(CircleF cir, Graphics g, Pen p)
 {
     using (GraphicsPath path = cir.GetShape(30, PathPointType.Line))
         g.DrawPath(p, path);
 }
예제 #17
0
 public float AreaOfIntersect(CircleF circle)
 { return CircleF.AreaOfIntersect(this, circle); }
예제 #18
0
 public static void FillShape(CircleF cir, Graphics g, Brush b)
 {
     using (GraphicsPath path = cir.GetShape(60, PathPointType.Bezier))
         g.FillPath(b, path);
 }
예제 #19
0
 public static float AngleOfPoint(CircleF cir, float x, float y)
 {
     return AngleOfPoint(cir, new PointF(x, y));
 }
예제 #20
0
 public Point GetPointAtAngle(float degree)
 {
     return(Point.Truncate(CircleF.PointAtAngle(CircleF.FromCircle(this), degree)));
 }
예제 #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);
        }
예제 #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))));
 }
예제 #23
0
 public static void FillShape(CircleF cir, Graphics g, Brush b)
 {
     using (GraphicsPath path = cir.GetShape(60, PathPointType.Bezier))
         g.FillPath(b, path);
 }
예제 #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)));
 }