Skip to content

Instantly share code, notes, and snippets.

@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]
@pgtwitter
pgtwitter / .py
Created June 2, 2024 04:43
Grayscale Using Fieldler Vector
# %%
import bpy
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)]
fiedler_vector = nx.fiedler_vector(S[0])
minV = min(fiedler_vector)
@pgtwitter
pgtwitter / .py
Last active June 1, 2024 06:29
フィードラーベクトルの応用 ( bun_zipper.ply は https://graphics.stanford.edu/data/3Dscanrep/ から)
# %%
import open3d as o3d
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
import matplotlib.animation as animation
# %%
mesh = o3d.io.read_triangle_mesh("bun_zipper.ply")
coordinates = mesh.vertices
edges = []
@pgtwitter
pgtwitter / .py
Created May 29, 2024 14:31
matplotlibの画像を貼ったnodeを用いたgraphviz
# %%
import tempfile
import scipy.interpolate as scipl
import networkx as nx
import graphviz
import numpy as np
import matplotlib.pyplot as plt
es0 = [
[1, 4],
@pgtwitter
pgtwitter / a.java
Created May 28, 2024 02:43
Stream, Collectors
import java.util.List;
import java.util.stream.Collectors;
import java.util.Arrays;
import java.util.Collections;
class a {
public static void main(String[] args) {
Integer[] array= new Integer[] {1, 2, 3, 4, 5};
List<Integer> list= Arrays.asList(array);
System.err.println("sum:"+list.stream().mapToInt(Integer::intValue).sum());
@pgtwitter
pgtwitter / .py
Last active May 29, 2024 13:50
Eigenvector Centrality
# %%
import scipy.interpolate as scipl
import networkx as nx
import graphviz
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
es0 = [
[1, 4],
[4, 3],
@pgtwitter
pgtwitter / shichijyuunikou72_2024.ics
Last active February 13, 2024 01:11
2024年 七十二候 iCalenderファイル
BEGIN:VCALENDAR
VERSION:2.0
PRODID:p_g_
X-WR-CALNAME:七十二候
BEGIN:VEVENT
DTSTART;TZID=Asia/Tokyo;VALUE=DATE:20240101
DTEND;TZID=Asia/Tokyo;VALUE=DATE:20240101
SUMMARY:雪下出麦(ゆきわたりてむぎのびる) - 冬至
URL;VALUE=URI:https://ja.wikipedia.org/wiki/%E5%86%AC%E8%87%B3%23%E4%B8%83%E5%8D%81%E4%BA%8C%E5%80%99
BEGIN:VALARM
@pgtwitter
pgtwitter / nijyuushisekki24_2024.ics
Last active February 13, 2024 01:12
2024年 二十四節気 iCalenderファイル
BEGIN:VCALENDAR
VERSION:2.0
PRODID:p_g_
X-WR-CALNAME:二十四節気
BEGIN:VEVENT
DTSTART;TZID=Asia/Tokyo;VALUE=DATE:20240106
DTEND;TZID=Asia/Tokyo;VALUE=DATE:20240106
SUMMARY:小寒
URL;VALUE=URI:https://ja.wikipedia.org/wiki/%E5%B0%8F%E5%AF%92
BEGIN:VALARM
@pgtwitter
pgtwitter / .py
Created January 9, 2024 07:43
iDirのpngをoDirに連番のファイル名になるよう複写を作る
# %%
import glob
import shutil
import os
iDir = '/Users/Work/Downloads'
oDir = '/Users/Work/Desktop/out'
if not os.path.isdir(oDir):
os.makedirs(oDir)
for idx, f in enumerate(sorted(glob.glob(iDir + '/*.png'))):
print(f)
@pgtwitter
pgtwitter / memo.py
Created December 28, 2023 13:06
Physics(rigid body等)で動かした後の位置と座標を得る方法
#emptyを追加
#emptyのparentを目的物にする
bpy.data.objects["Empty"].matrix_world
bpy.data.objects["Empty"].matrix_world.to_euler('XYZ')