コード例 #1
0
        /// <summary>
        /// Tests if a point is inside the circle defined by
        /// the triangle with vertices a, b, c (oriented counter-clockwise).
        /// </summary>
        /// <remarks>
        /// The computation uses <see cref="DD"/> arithmetic for robustness, but a faster approach.
        /// </remarks>
        /// <param name="a">A vertex of the triangle</param>
        /// <param name="b">A vertex of the triangle</param>
        /// <param name="c">A vertex of the triangle</param>
        /// <param name="p">The point to test</param>
        /// <returns>true if this point is inside the circle defined by the points a, b, c</returns>
        public static bool IsInCircleDDFast(
            Coordinate a, Coordinate b, Coordinate c,
            Coordinate p)
        {
            var aTerm = (DD.Sqr(a.X) + DD.Sqr(a.Y)) * TriAreaDDFast(b, c, p);
            var bTerm = (DD.Sqr(b.X) + DD.Sqr(b.Y)) * TriAreaDDFast(a, c, p);
            var cTerm = (DD.Sqr(c.X) + DD.Sqr(c.Y)) * TriAreaDDFast(a, b, p);
            var pTerm = (DD.Sqr(p.X) + DD.Sqr(p.Y)) * TriAreaDDFast(a, b, c);

            var  sum        = aTerm - bTerm + cTerm - pTerm;
            bool isInCircle = sum.ToDoubleValue() > 0;

            return(isInCircle);
        }
コード例 #2
0
        /// <summary>
        /// Tests if a point is inside the circle defined by the points a, b, c.
        /// The computation uses <see cref="NetTopologySuite.Mathematics.DD"/> arithmetic for robustness.
        /// </summary>
        /// <param name="a">A vertex of the triangle</param>
        /// <param name="b">A vertex of the triangle</param>
        /// <param name="c">A vertex of the triangle</param>
        /// <param name="p">The point to test</param>
        /// <returns><value>true</value> if this point is inside the circle defined by the points a, b, c</returns>
        public static bool IsInCircleDD2(
            Coordinate a, Coordinate b, Coordinate c,
            Coordinate p)
        {
            DD aTerm = (DD.Sqr(a.X) + DD.Sqr(a.Y)) * TriAreaDD2(b, c, p);
            DD bTerm = (DD.Sqr(b.X) + DD.Sqr(b.Y)) * TriAreaDD2(a, c, p);
            DD cTerm = (DD.Sqr(c.X) + DD.Sqr(c.Y)) * TriAreaDD2(a, b, p);
            DD pTerm = (DD.Sqr(p.X) + DD.Sqr(p.Y)) * TriAreaDD2(a, b, c);

            DD  sum        = aTerm - bTerm + cTerm - pTerm;
            var isInCircle = sum.ToDoubleValue() > 0;

            return(isInCircle);
        }
コード例 #3
0
        /// <summary>
        /// This routine simply tests for robustness of the toString function.
        /// </summary>
        static void WriteRepeatedSqr(DD xdd)
        {
            if (xdd.GreaterOrEqualThan(DD.ValueOf(1)))
            {
                throw new ArgumentException("Argument must be < 1");
            }

            int count = 0;

            while (xdd.ToDoubleValue() > 1e-300)
            {
                count++;
                double x    = xdd.ToDoubleValue();
                var    xSqr = xdd.Sqr();
                string s    = xSqr.ToString();
                // System.Console.WriteLine(count + ": " + s);

                var xSqr2 = DD.Parse(s);

                xdd = xSqr;
            }
        }
コード例 #4
0
	/**
	 * This routine simply tests for robustness of the toString function.
	 * 
	 * @param xdd
	 */
	static void WriteRepeatedSqr(DD xdd) 
	{
		if (xdd.GreaterOrEqualThan(DD.ValueOf(1)))
			throw new ArgumentException("Argument must be < 1");
		
		int count = 0;
		while (xdd.ToDoubleValue() > 1e-300) {
			count++;
			double x = xdd.ToDoubleValue();
			DD xSqr = xdd.Sqr();
			String s = xSqr.ToString();
			Console.WriteLine(count + ": " + s);

			DD xSqr2 = DD.Parse(s);
	
			xdd = xSqr;
		}
	}