2023年3月19日日曜日

mosaku kaisi速度 電車全長 2単位 # Set the speed multiplier a =3.0

aaa





import bpy
import math

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

# Set start and end frames
start_frame = 1
end_frame = 200
repeat_frame = 240

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

# Set the speed multiplier
a =3.0

# Calculate the distance between start_pos and middle_pos, and between middle_pos and end_pos
start_middle_dist = math.sqrt((start_pos[0]-middle_pos[0])**2 + (start_pos[1]-middle_pos[1])**2 + (start_pos[2]-middle_pos[2])**2)
middle_end_dist = math.sqrt((middle_pos[0]-end_pos[0])**2 + (middle_pos[1]-end_pos[1])**2 + (middle_pos[2]-end_pos[2])**2)

# Calculate the time it takes to move from start_pos to middle_pos and from middle_pos to end_pos
start_middle_time = int((end_frame - start_frame) * (start_middle_dist / (start_middle_dist + middle_end_dist)) * 1.41 / a)
middle_end_time = int((end_frame - start_frame) * (middle_end_dist / (start_middle_dist + middle_end_dist)) * 1.0 / a)

# Move the sphere to the middle point over the first half of the animation time
for i in range(start_frame, start_frame + start_middle_time + 1):
    frame_factor = ((i-start_frame)/(start_middle_time) * 2)**0.5
    bpy.context.scene.frame_set(i)
    bpy.context.object.location = tuple(s*(1-frame_factor) + m*frame_factor for s,m in zip(start_pos, middle_pos))
    bpy.context.object.keyframe_insert(data_path="location", index=-1)

# Move the sphere from the middle point to the end point over the second half of the animation time
for i in range(start_frame + start_middle_time + 1, end_frame + 1):
    frame_factor = ((i-start_frame-start_middle_time)/(middle_end_time) * 2)**0.5
    bpy.context.scene.frame_set(i)
    bpy.context.object.location = tuple(m*(1-frame_factor) + e*frame_factor for m,e in zip(middle_pos, end_pos))
    bpy.context.object.keyframe_insert(data_path="location", index=-1)

# Stop the sphere from moving after reaching the end position
bpy.context.scene.frame_set(end_frame)
bpy.context.object.keyframe_insert(data_path="location", index=-1)

# Repeat the animation after 5 seconds
for i in range(end_frame+1, repeat_frame+1):
    bpy.context.scene.frame_set(i)
    bpy.context.object.location = end_pos
    bpy.context.object.keyframe_insert(data_path="location", index=-1)






import bpy
import math

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

# Set start and end frames
start_frame = 1
end_frame = 200
repeat_frame = 240

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








import bpy

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

# Set start and end frames
start_frame = 1
end_frame = 200
repeat_frame = 240

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

# Move the sphere from the start position to the end position over the animation time
for i in range(start_frame, end_frame + 1):
    frame_factor = (i - start_frame) / (end_frame - start_frame)
    bpy.context.scene.frame_set(i)
    bpy.context.object.location = tuple(s*(1-frame_factor) + e*frame_factor for s,e in zip(start_pos, end_pos))
    bpy.context.object.keyframe_insert(data_path="location", index=-1)

# Stop the sphere from moving after reaching the end position
bpy.context.scene.frame_set(end_frame)
bpy.context.object.keyframe_insert(data_path="location", index=-1)

# Repeat the animation after 4 seconds
for i in range(end_frame+1, repeat_frame+1):
    bpy.context.scene.frame_set(i)
    bpy.context.object.location = end_pos
    bpy.context.object.keyframe_insert(data_path="location", index=-1)



















bbb

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

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