Esempio n. 1
0
        private void ReflectInternal(Circle c)
        {
            // Reflecting to a line?
            if (IsPointOn(c.Center))
            {
                // Grab 2 points to reflect to P1/P2.
                // We'll use the 2 points that are 120 degrees from c.Center.
                Vector3D v = c.Center - this.Center;
                v.RotateXY(2 * Math.PI / 3);
                P1 = c.ReflectPoint(this.Center + v);
                v.RotateXY(2 * Math.PI / 3);
                P2 = c.ReflectPoint(this.Center + v);

                Radius = double.PositiveInfinity;
                Center.Empty();
            }
            else
            {
                // NOTE: We can't just reflect the center.
                //		 See http://mathworld.wolfram.com/Inversion.html
                double   a = Radius;
                double   k = c.Radius;
                Vector3D v = Center - c.Center;
                double   s = k * k / (v.MagSquared() - a * a);
                Center = c.Center + v * s;
                Radius = Math.Abs(s) * a;
                P1.Empty();
                P2.Empty();
            }
        }