2023年3月19日日曜日

aaa





import bpy
import math

# Create a sphere object
bpy.ops.mesh.primitive_uv_sphere_add(radius=1.0, location=(-30.0, 0.0, 0.0))

# Set start and end frames
start_frame = 1
end_frame = 100

# Define the start, middle, and end positions
start_pos = (0.0, 0.0, 0.0)
middle_pos = (30.0, 0.0, 0.0)
end_pos = (0.0, -30.0, 0.0)

# Define velocities based on distance and time
dist1 = math.sqrt(sum([(middle_pos[i] - start_pos[i])**2 for i in range(3)]))
dist2 = math.sqrt(sum([(end_pos[i] - middle_pos[i])**2 for i in range(3)]))
time1 = (dist1 / 1.0) * 25.0  # Speed of 1 unit/frame
time2 = (dist2 / 1.0) * 25.0  # Speed of 1/1.41 unit/frame
vel1 = [(middle_pos[i] - start_pos[i]) / time1 for i in range(3)]
vel2 = [(end_pos[i] - middle_pos[i]) / time2 for i in range(3)]

# Animate the sphere's movement
for frame in range(start_frame, end_frame+1):
    if frame < start_frame + time1:
        # Move towards middle position
        pos = [start_pos[i] + vel1[i] * (frame-start_frame) for i in range(3)]
    elif frame < end_frame - time2:
        # Move at slower speed towards end position
        pos = [middle_pos[i] + vel2[i] * (frame-(start_frame+time1)) for i in range(3)]
    else:
        # Move towards end position
        pos = [end_pos[i] - vel1[i] * (end_frame-frame) for i in range(3)]
    bpy.context.object.location = pos
    bpy.context.object.keyframe_insert(data_path="location", index=-1, frame=frame)






This code creates a sphere object with an initial location of (-30.0, 0.0, 0.0), and animates its movement from that location to the middle position (30.0, 0.0, 0.0), and then to the end position (0.0, -30.0, 0.0). The sphere travels at a speed of 1 unit/frame from the start position to the middle position, and then at a speed of 1/1.41 units/frame from the middle position to the end position. The animation runs for 100 frames.



























bbb

連番 007 未来光円錐 過去光円錐 円周中心からの球体放出

aaa 参考 2023年3月26日日曜日 製作 002b 未来光円錐の方向 線路レールで https://ia2023sha.blogspot.com/2023/03/002b.html import bpy import math zion_co...