2023年8月4日金曜日

20230804 bbb 球体追加の 現在時点の ミンコフスキー時空型

 







import bpy

import mathutils

import math


# 円周の中心座標

center_x = 0

center_y = 0

center_z = 0


# 円周の半径

radius = 6

# 円周に配置する円錐の数

num_cones = 12


# 円錐の底面が遠くなる位置を定義(例えば、X=2, Y=2, Z=2の場合)

target_x = 0

target_y = 0

target_z = 6


# 円周上の点を計算する

theta_values = [2 * math.pi * i / num_cones for i in range(num_cones)]

circle_points = [(center_x + radius * math.cos(theta), center_y + radius * math.sin(theta), center_z) for theta in theta_values]


# 円錐を配置する関数

def place_cone(position, direction):

    bpy.ops.mesh.primitive_cone_add(vertices=32, radius1=0.2, depth=24, location=position)

    cone = bpy.context.active_object

    bpy.context.view_layer.objects.active = cone


    # 向きを設定

    cone.rotation_euler = direction


# トーラスを描く関数

def draw_torus():

    bpy.ops.mesh.primitive_torus_add(location=(center_x, center_y, center_z), align='WORLD', major_radius=radius+0.0, minor_radius=0.1)


# 球体を追加する関数

def add_sphere(position, radius):

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


# 円錐を配置

for point in circle_points:

    # (0, 0, 0)への方向を計算

    target_vector = mathutils.Vector((target_x - point[0], target_y - point[1], target_z - point[2]))

    direction_rotation = target_vector.to_track_quat('Z', 'Y').to_euler()


    # 円錐の配置

    place_cone(point, direction_rotation)


# トーラスの描画

draw_torus()


# 球体の追加

add_sphere((target_x, target_y, target_z), 0.3)




















https://mokuji000zionad.hatenablog.com/

配布ファイル 20231005 遠近法モード 表示画面の大きさ

  今日の書き出し設定 項目メモ帳 2023: 20231005   立方体と 光線 https://2023na2022.blogspot.com/2023/10/20231005.html https://mokuji000zionad.hatenablog.com/