Exemple #1
0
def circle(n):
    circle = Circle2D(10, 10, 10)
    circlepoints = circle.create_random_points(n)
    #print(random_circle_points)
    x = np.asarray(circlepoints)
    plt.scatter(x[:, 0], x[:, 1], c='g')
    #plt.scatter(x[:,0],x[:,1])
    return x
Exemple #2
0
def _get_valid_circle_definitions():
    """Create a list of valid 2D circle parameters.

    Create and return a static list of tuples each containing the parameters of
    a 2D circle along with the desired number of random points to be created.

    Returns:
        list (tuple (Circle2D, int) ): List with 2D circle parameters and desired point count
    """
    return [(Circle2D(3.0, 5.0, 10.0), 5), (Circle2D(3.0, 5.0, 1.0), 10),
            (Circle2D(-2.0, 4.0, 5.0), 20), (Circle2D(3.55, -44.2,
                                                      5422.5), 100),
            (Circle2D(200, 1070, 55), 5), (Circle2D(4.5, 10, 4), 5),
            (Circle2D(10000.78, 99453.44, 10455.6), 5),
            (Circle2D(-55466.4, -22331.5, 99002.5), 5),
            (Circle2D(0.005, -0.00064, 0.00085), 5),
            (Circle2D(0.005, -0.00064, 0.00085), 99999)]
Exemple #3
0
def _get_circle_point_creator(circle_model):
    """Convert a circle model into a random_geometry_points.circle2d.Circle2D.

    Args:
        circle_model (..models.circle2d.Circle2D): The input circle model

    Returns:
        random_geometry_points.circle2d.Circle2D : The converted circle definition
    """
    return Circle2D(circle_model.center_x, circle_model.center_y, circle_model.radius)
Exemple #4
0
def _get_circles_with_invalid_point_count():
    """Create a list of 2D circle parameters and invalid point count values.

    Create and return a list of tuples each containing valid 2D circle parameters
    along with an invalid number of desired random points.

    An invalid number is either a value of wrong type or with an invalid value.

    Returns:
        list (tuple (Circle2D, any): List with 2D circle parameters
          and an invalid number of random points
    """
    return [(Circle2D(2.0, 5.0, 5), "3", TypeError),
            (Circle2D(2.0, 5.0, 5), "test", TypeError),
            (Circle2D(2.0, 5.0, 5), 4.5, TypeError),
            (Circle2D(2.0, 5.0, 5), -5, ValueError),
            (Circle2D(2.0, 5.0, 5), 0, ValueError),
            (Circle2D(2.0, 5.0, 5), 100000, ValueError),
            (Circle2D(2.0, 5.0, 5), float('nan'), TypeError),
            (Circle2D(2.0, 5.0, 5), float("inf"), TypeError),
            (Circle2D(2.0, 5.0, 5), float("-inf"), TypeError)]
Exemple #5
0
def alltogether(n):
    P1 = np.random.uniform(low=0, high=10, size=(n, 2))
    P1[:, 1] = (P1[:, 0] * 2) + 3

    j = n / 5
    j = round(j)
    x = np.array([(x, j) for x in range(0, j + 1)])
    x = np.concatenate((x, ([(0, x) for x in range(0, j + 1)])), axis=0)
    x = np.concatenate((x, ([(x, 0) for x in range(0, j + 1)])), axis=0)
    x = np.concatenate((x, ([(j, x) for x in range(0, j + 1)])), axis=0)

    P1 = np.concatenate((P1, x))

    circle = Circle2D(150, 100, 100)
    #circle = Circle2D(750, 750, 700)
    circlepoints = circle.create_random_points(n)

    y = np.asarray(circlepoints)

    P1 = np.concatenate((P1, y))
    print("Length of pointset is ", len(P1))
    plt.scatter(P1[:, 0], P1[:, 1], c='g')
    return P1
Exemple #6
0
def Circular(n):
    tu = Circle2D(100, 100, 50)
    Pt = tu.create_random_points(n)
    return Pt
Exemple #7
0
 def check_circle_creation(center_x, center_y, radius, expected_exception):
     """Check the circle parameters to raise the expected exception
     """
     with pytest.raises(expected_exception):
         Circle2D(center_x, center_y, radius)