Example #1
0
        /// <summary>
        /// Normalize so P1 is closest point to origin,
        /// and direction vector is of unit length.
        /// </summary>
        public void NormalizeLine()
        {
            if (!this.IsLine)
            {
                return;
            }

            Vector3D d = P2 - P1;

            d.Normalize();

            P1 = Euclidean2D.ProjectOntoLine(new Vector3D(), P1, P2);

            // ZZZ - Could probably do something more robust to choose proper direction.
            if (Tolerance.GreaterThanOrEqual(Euclidean2D.AngleToClock(d, new Vector3D(1, 0)), Math.PI))
            {
                d *= -1;
            }

            P2 = P1 + d;
        }
Example #2
0
        public static Circle3D GetCircleForBallPoint(Vector3D p)
        {
            Sphere ball = new Sphere();

            p = SphericalModels.GnomonicToStereo(p);

            if (Tolerance.GreaterThanOrEqual(p.Abs(), 1))
            {
                return(null);
            }

            Sphere t = H3Models.Ball.OrthogonalSphereInterior(p);

            //return H3Models.Ball.IdealCircle( t );

            // Get the corresponding point on the exterior (our inversion).
            p = HyperbolicModels.PoincareToKlein(p);
            p = HyperbolicModels.PoincareToKlein(p);
            p = ball.ReflectPoint(p);

            return(GetCircle(p));
        }