Blender的AI模型delaunay三角化拓扑

https://zhuanlan.zhihu.com/p/459884570
https://devtalk.blender.org/t/delaunay-2d-cdt-robustness/10968/11

python 复制代码
from itertools import cycle, chain
from numpy import arange
import bpy
import bmesh
from mathutils import Vector
from mathutils.geometry import delaunay_2d_cdt

number_of_edges = 100

def generate_edges(number):
    # like this: | | | | | | | |
    x_iter = chain.from_iterable(zip(arange(0, number * 0.1, 0.1), arange(0, number * 0.1, 0.1)))
    vs = [Vector((x, y)) for x, y in zip(x_iter, cycle([0, 1]))]
    es = [(i, i + 1) for i in range(0, number * 2, 2)]
    return vs, es

verts, edges = generate_edges(number_of_edges)
verts += [Vector((-0.1, 0.5)), Vector((number_of_edges * 0.1, 0.5))]
edges += [(number_of_edges * 2, number_of_edges * 2 + 1)]
verts_new, edges_new, faces_new, _, _, _ = delaunay_2d_cdt(verts, edges, [], 2, 1e-5)

print(f'Done intersections: {number_of_edges}')

bm = bmesh.new()
vs = [bm.verts.new(v.to_3d()) for v in verts_new]
[bm.edges.new([vs[i1], vs[i2]]) for i1, i2 in edges_new]
me = bpy.data.meshes.new("InterTest")
bm.to_mesh(me)
bm.free()
obj = bpy.data.objects.new("Intersection test", me)
bpy.context.collection.objects.link(obj)
相关推荐
菜冻鱼5 天前
Python-sklearn-SVM
开发语言·人工智能·python·机器学习·支持向量机·numpy·sklearn
菜冻鱼6 天前
Python-sklearn-评估指标
开发语言·人工智能·python·机器学习·numpy·pandas·sklearn
菜冻鱼6 天前
Python-sklearn-模型选择
开发语言·人工智能·python·机器学习·numpy·pandas·sklearn
菜冻鱼6 天前
Python-sklearn-特征工程
开发语言·人工智能·python·机器学习·numpy·matplotlib·sklearn
菜冻鱼10 天前
Python-pandas-索引与筛选
开发语言·笔记·python·numpy·pandas·学习方法
小趴蔡ha11 天前
03 NumPy 入门:机器学习中的数组和矩阵
python·线性代数·机器学习·numpy
乱七八糟的屋子13 天前
【C++数值计算】NumCpp超详细入门教程(纯正Numpy语法、零学习成本、C++首选科学计算库、性能压测对比)
c++·数值计算·numpy·高性能计算·科学计算·ndarray
Lee_jerome14 天前
python神经网络编程入门(二十)——RNN LSTM 数学原理与结构拆解
深度学习·numpy·lstm·参数量·sigmoid·tanh·门控机制
赤羽尾风14 天前
NumPy快速入门
python·numpy
Xiaok101815 天前
NumPy 数组 vs PyTorch Tensor
人工智能·pytorch·numpy