start_pos = (0.0, 0.0, 0.0)
middle_pos = (30.0, 0.0, 0.0)の移動時間の1.41 倍にして
middle_pos = (30.0, 0.0, 0.0)
end_pos = (0.0, -30.0, 0.0)の移動時間を
import bpy
# Create a sphere object
bpy.ops.mesh.primitive_uv_sphere_add(radius=1.0, location=(0.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)
# Calculate the distance between start_pos and middle_pos
start_middle_dist = ((start_pos[0]-middle_pos[0])**2 + (start_pos[1]-middle_pos[1])**2 + (start_pos[2]-middle_pos[2])**2)**0.5
# Move the sphere to the middle point over half of the animation time
for i in range(start_frame, int((start_frame+end_frame)/2)+1):
frame_factor = ((i-start_frame)/(end_frame-start_frame) * 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(int((start_frame+end_frame)/2)+1, end_frame+1):
frame_factor = ((i-int((start_frame+end_frame)/2))/(end_frame-start_frame) * 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)
middle_pos = (0.0, 0.0, 0.0) を
end_pos = (0.0, -30.0, 0.0)の速度を 1/1.41 にして
bbb