Exemple #1
0
def generate_grid(center, density, radius):
    """
    Generate a list of x, y coordinates confined to the inside of a circle with
    specified center point and radius. The density is how many points per
    single coordinate unit
    :param center: The (x, y) center of the circle
    :param density: How many points per x/y unit
    :param radius: The radius of the circle
    :return: List of (x, y) point grid inside the circle
    """
    # Boundaries
    top = center[1] + radius
    bottom = center[1] - radius
    left = center[0] - radius
    right = center[0] + radius

    # Get Points
    for y in number.drange(bottom, top, 1 / density):
        for x in number.drange(left, right, 1 / density):
            if point_in_circle(center, radius, (x, y)):
                yield (x, y)
Exemple #2
0
def test_drange_greater_than_one():
    eq_(list(number.drange(0, 6, 2)), [0, 2, 4, 6])
Exemple #3
0
def test_drange_less_than_one():
    eq_(list(number.drange(0, 2, 0.5)), [0, 0.5, 1, 1.5, 2])