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)
相关推荐
m沐沐13 天前
【计算机视觉】OpenCV 模板匹配银行卡数字识别---下
人工智能·python·opencv·计算机视觉·pycharm·numpy
云和数据.ChenGuang15 天前
大模型厂商常用的数据库有哪些?
数据库·人工智能·pytorch·深度学习·numpy
MATLAB代码顾问16 天前
Python NumPy数值计算核心指南
开发语言·python·numpy
FBI HackerHarry浩16 天前
解决pip 安装 numpy 时元数据生成失败
numpy·pip
m沐沐18 天前
【计算机视觉】OpenCV 模板匹配银行卡数字识别---上
人工智能·后端·python·opencv·计算机视觉·pycharm·numpy
iRayCheung20 天前
virtualbox安装的ubuntu系统跑numpy报错
linux·ubuntu·numpy
SilentSamsara21 天前
scikit-learn 工作流工程化:Pipeline、ColumnTransformer 与自定义转换器
开发语言·人工智能·python·机器学习·青少年编程·numpy·scikit-learn
SilentSamsara22 天前
NumPy 进阶:广播机制、ufunc 与向量化计算的工程实践
开发语言·python·青少年编程·性能优化·numpy
DogDaoDao22 天前
【第 04 篇】列表与元组 —— 序列类型核心详解
人工智能·python·深度学习·神经网络·机器学习·conda·numpy
zyl8372122 天前
Python NumPy 学习
python·学习·numpy