K
K
krist1k2020-02-11 19:48:41
Python
krist1k, 2020-02-11 19:48:41

Machine generated artistic patterns in vector fields?

I'm trying to rewrite this article:
Machine learning has just started to study, hence the following question arises: How to build a grid of corners and display it through PyCharm? I am at this stage:

import numpy as np
import math
import matplotlib.pyplot as plt

width = 100
height = 100

left_x = int(width * -0.5)
right_x = int(width * 1.5)
top_y = int(height * -0.5)
bottom_y = int(height * 1.5)

resolution = int(width * 0.01)

num_columns = int((right_x - left_x) / resolution)
num_rows = int((bottom_y - top_y) / resolution)

grid = np.random.random((num_columns, num_rows))

default_angle = math.pi * 0.25

for columns in range(num_columns):
    for row in range(num_rows):
        grid[columns][row] = default_angle


In this code, I am creating a grid array with 200 rows and 200 columns, which are filled with the 'default_angle' angle. Please tell me if I'm moving in the right direction and how to "draw" the grid, as in the attached link. I guess you need to use matplotlib.

I will be grateful for any constructive answer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
U235U235, 2020-02-11
@U235U235

Why are you assigning random numbers to grid and then changing them to default_angle?

grid=np.ndarray((num_columns, num_rows))
grid[:,:]=math.pi * 0.25

and no cycle needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question