Beispiel #1
0
        /// <summary>
        /// Finds a random point within the spherical annulus by drawing a
        /// vector whose magnitude is between `r` and `2r` at a random angle.
        /// </summary>
        /// <param name="origin">donut center</param>
        /// <returns>random sample</returns>
        private Vertex getRandomPointAround(Vertex origin)
        {
            float magnitude = Random.Range(minDistance, maxDistance);
            float angle     = Random.Range(0f, 360f);

            return(new Vertex(Mathy.getEndpointOfLineRotation(origin.x, origin.y, angle, magnitude)));
        }
Beispiel #2
0
        public void testGetEndpointOfLineRotationQuadrant4Unsigned()
        {
            double theta    = 315.0 * Mathf.Deg2Rad;
            double x        = 0;
            double y        = 0;
            float  distance = 5;

            double[] result = Mathy.getEndpointOfLineRotation(x, y, theta, distance);
            // Check separately due to floating point precision, within 5 points
            Assert.AreEqual(5.0, result[0], 5);
            Assert.AreEqual(-5.0, result[1], 5);
        }