Skip to content

Instantly share code, notes, and snippets.

@pgtwitter
pgtwitter / a.ipynb
Created August 25, 2024 11:44
円周率1万桁の中に1から数えていって入っていない最初数は何か?
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgtwitter
pgtwitter / a.sh
Last active August 24, 2024 14:23
360mp4: Blender, Camera/Panoramic/Equirectangular, Stereoscopy/Multi-View. Views Format/Indivisual
#! /bin/sh -x
DIR=`pwd`
FPS=24
S_NUMBER=83
LOOP=10
STEREO="left-right" #"top-bottom"
DIST_PREFIX="dist"
SRC_DIR="360"
DIST_DIR=${DIR}
@pgtwitter
pgtwitter / a.ipynb
Created August 7, 2024 14:11
rendering network with networkx (extends Maze)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgtwitter
pgtwitter / a.ipynb
Created August 7, 2024 01:48
rendering network with networkx
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgtwitter
pgtwitter / a.ipynb
Last active July 21, 2024 06:39
半径0.5の外接円を持つ正n角形の周の長さ
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgtwitter
pgtwitter / py.ipynb
Created July 20, 2024 06:45
Monte Carlo method
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# %%
import stanza
import graphviz as gv
# %%
# https://qiita.com/ytaki0801/items/b8d7d4c778fe98966ce5
def p_lex(p):
for s in '()[]{}",':
@pgtwitter
pgtwitter / py.ipynb
Last active June 10, 2024 02:24
モンテカルロ法的な積分 ( 参考 https://x.com/nichimath/status/1799033564094230546 )
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgtwitter
pgtwitter / .py
Created June 5, 2024 09:12
Convex hull division using Fiedler vectors
# %%
import bpy
import networkx as nx # /path/to/blender's/python -m pip install scipy networkx
import numpy as np
from scipy.spatial import ConvexHull
def obj2GraphAndXyzAndNormFiedler(obj):
edges = [(e.vertices[0], e.vertices[1]) for e in obj.data.edges]
G = nx.Graph(edges)
@pgtwitter
pgtwitter / .py
Created June 2, 2024 06:48
Grayscale Using Fieldler Vector
# %%
import bpy
from sklearn.cluster import KMeans # /path/to/blender's/python -m pip install scikit-learn
import networkx as nx # /path/to/blender's/python -m pip install scipy networkx
obj = bpy.data.objects['Armadillo']
mesh = obj.data
edges = [(e.vertices[0], e.vertices[1]) for e in mesh.edges]
G = nx.Graph(edges)
S = [G.subgraph(c).copy() for c in nx.connected_components(G)]
G = S[0]