{{ message }}

Instantly share code, notes, and snippets.

# Nicolas P. Rougier rougier

Created Nov 15, 2016
Poisson disk sampling
View poisson-disk-sampling.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 def poisson_disk_sample(width=1.0, height=1.0, radius=0.025, k=30): # References: Fast Poisson Disk Sampling in Arbitrary Dimensions # Robert Bridson, SIGGRAPH, 2007 def squared_distance(p0, p1): return (p0[0]-p1[0])**2 + (p0[1]-p1[1])**2 def random_point_around(p, k=1): # WARNING: This is not uniform around p but we can live with it R = np.random.uniform(radius, 2*radius, k) T = np.random.uniform(0, 2*np.pi, k)
Created Nov 27, 2016
Matplotlib / individual rotation markers using a single path
View marker-rotation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Matplotlib / individual rotation markers using a single path import numpy as np import matplotlib.pyplot as plt from matplotlib.path import Path from matplotlib.animation import FuncAnimation from matplotlib.collections import PathCollection triangle = [[(-0.25, -0.5), (+0.0, +0.5), (+0.25, -0.5), (+0.0, +0.0)],
Created Feb 17, 2017 — forked from jakevdp/convolution_matrix.py
Convolution Matrix
View convolution_matrix.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Author: Jake VanderPlas # LICENSE: MIT from __future__ import division import numpy as np def convolution_matrix(x, N=None, mode='full'): """Compute the Convolution Matrix
Last active Feb 24, 2017
Cellular automata 1D
View cellular-automata-1d.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Copyright (2017) Nicolas P. Rougier - BSD license # Twitter version (140 characters) # -------------------------------- _='0' R,C="{:08b}".format(30),_*9+'1'+_*9 for k in range(9): print(C) C = _+''.join([R[7-eval('0b'+C[i:i+3])] for i in range(len(C)-2)])+_
Created Sep 16, 2017 — forked from MorganBorman/main.py
A short example of how to use vertex array objects in PyOpenGL
View main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 import OpenGL.GL as GL import OpenGL.GL.shaders import ctypes import pygame import numpy vertex_shader = """ #version 330 in vec4 position;
Created Jul 7, 2018 — forked from stucchio/beta_bandit.py
The beta-distribution based bayesian bandit algorith,.
View beta_bandit.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 from numpy import * from scipy.stats import beta class BetaBandit(object): def __init__(self, num_options=2, prior=(1.0,1.0)): self.trials = zeros(shape=(num_options,), dtype=int) self.successes = zeros(shape=(num_options,), dtype=int) self.num_options = num_options self.prior = prior
Created Aug 20, 2019 — forked from mikhailov-work/turbo_colormap.py
Turbo Colormap Look-up Table
View turbo_colormap.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Created Sep 8, 2019
Numpy logo redesign
View numpy-logo.svg