Exemplo n.º 1
0
        /// <summary>
        /// kruznice zadana dvema body na obvodu a polomerem
        /// , pokud je polomer mensi nez polovina vzdalenosti bodu, umisti se stred kruznice do stredoveho bodu tvoriciho obema ridicimi body
        /// , stred kruznice se umisti do poloroviny urcene ridicimi body, podle znamenka polomeru
        /// </summary>
        /// <param name="pt1">prvni bod na obvodu</param>
        /// <param name="pt2">druhy bod na ovodu</param>
        /// <param name="r">polomer</param>
        public Circle2D(Point pt1, Point pt2, double r)
        {
            double d = Funcs2D.Distance(pt1, pt2) / 2;

            if (Math.Abs(r) <= d)
            {
                Radius = d;
                Center = new Point((pt1.X + pt2.X) / 2, (pt1.Y + pt2.Y) / 2);
            }
            else
            {
                Radius = Math.Abs(r);
                double v = Math.Sqrt(Math.Pow(Radius, 2) - Math.Pow(d, 2));
                Center = Funcs2D.LineRelPtOffset(pt1, pt2, 0.5, r < 0 ? -v : v);
            }
        }