mathematical-lattices

Get all lattice points lying inside a Shapely polygon

孤街醉人 提交于 2021-02-13 12:17:35
问题 I need to find all the lattice points inside and on a polygon. Input: from shapely.geometry import Polygon, mapping sh_polygon = Polygon(((0,0), (2,0), (2,2), (0,2))) Output: (0, 0), (1, 0), (2, 0), (0, 1), (1, 1), (2, 1), (0, 2), (1, 2), (2, 2) Please suggest if there is a way to get the expected result with or without using Shapely. I have written this piece of code that gives points inside the polygon, but it doesn't give points on it. Also is there a better way to do the same thing: from

Plot lattice tree in Python

五迷三道 提交于 2021-01-05 06:12:09
问题 I'm seeking ideas to plot a tuple tree t = ((4,), (3, 5,), (2, 4, 6,), (1, 3, 5, 7,)) as the following image (assuming this binomial tree size can change). I'm trying to avoid dependencies on non-core packages (just sticking to pandas, numpy, matplotlib, scikit, and such). 回答1: I'm using this piece of code which gives a pretty good result: from matplotlib import pyplot as plt import numpy as np fig = plt.figure(figsize=[5, 5]) for i in range(3): x = [1, 0, 1] for j in range(i): x.append(0) x

Plot lattice tree in Python

☆樱花仙子☆ 提交于 2021-01-05 06:07:25
问题 I'm seeking ideas to plot a tuple tree t = ((4,), (3, 5,), (2, 4, 6,), (1, 3, 5, 7,)) as the following image (assuming this binomial tree size can change). I'm trying to avoid dependencies on non-core packages (just sticking to pandas, numpy, matplotlib, scikit, and such). 回答1: I'm using this piece of code which gives a pretty good result: from matplotlib import pyplot as plt import numpy as np fig = plt.figure(figsize=[5, 5]) for i in range(3): x = [1, 0, 1] for j in range(i): x.append(0) x

Remove rotation effect when drawing a square grid of MxM nodes in networkx using grid_2d_graph

不羁的心 提交于 2019-12-21 05:01:09
问题 I need to generate a regular graph (also known as lattice network) which has 100x100 nodes. I started off with drawing a 10x10 graph with the following code: import numpy from numpy import * import networkx as nx from networkx import * import matplotlib.pyplot as plt G=nx.grid_2d_graph(10,10) nx.draw(G) plt.axis('off') plt.show() but what I get is this: Is there any way of getting rid of this sort of rotation effect the output has? My final network must look like a chess table, just like this

Is the Fibonacci lattice the very best way to evenly distribute N points on a sphere? So far it seems that it is the best

狂风中的少年 提交于 2019-12-11 13:48:15
问题 Over in the thread "Evenly distributing n points on a sphere" this topic is touched upon: Evenly distributing n points on a sphere. But what I would like to know is: "Is the Fibonacci lattice the very best way to evenly distribute N points on a sphere? So far it seems that it is the best. Does anyone know of a better method?" I have a Ph.D. in physics and may have an application for some of this research in physics. I came across this wonderful paper: http://arxiv.org/pdf/0912.4540.pdf

Remove rotation effect when drawing a square grid of MxM nodes in networkx using grid_2d_graph

别等时光非礼了梦想. 提交于 2019-12-03 15:27:35
I need to generate a regular graph (also known as lattice network) which has 100x100 nodes. I started off with drawing a 10x10 graph with the following code: import numpy from numpy import * import networkx as nx from networkx import * import matplotlib.pyplot as plt G=nx.grid_2d_graph(10,10) nx.draw(G) plt.axis('off') plt.show() but what I get is this: Is there any way of getting rid of this sort of rotation effect the output has? My final network must look like a chess table, just like this (please ignore the lables): Also, I need to give each node its ID, ranging from 0 to 9999 (in the case