2023年8月7日月曜日

20230808 球体で 長さイメージの到着を描く









aa


import bpy

import math

import mathutils


# 6個の球体を等間隔で配置する関数

def create_spheres_between_points(start, end, num_spheres):

    direction = (end - start).normalized()

    distance = (end - start).length

    interval_length = distance / (num_spheres - 1)

    

    for i in range(num_spheres):

        position = start + direction * (i * interval_length)

        bpy.ops.mesh.primitive_uv_sphere_add(radius=0.04, location=position)

        sphere = bpy.context.active_object

        sphere.name = f"{i:02} ({position.x:.2f},{position.y:.2f},{position.z:.2f})"


# A位置を定義

pointA = mathutils.Vector((0, 0, 0))


# 各区間ごとに6個の球体を作成

specified_positions = [

    mathutils.Vector((0, -1, 0)),

    mathutils.Vector((0, -1, 1)),

    mathutils.Vector((0, -1, 5)),

    mathutils.Vector((1, -1, 1)),

    mathutils.Vector((-1, -1, 1))

]


for pos in specified_positions:

    create_spheres_between_points(pos, pointA, 6)




aaa