Animate the points move along the curves with different speeds

Hi, im a beginner of Grasshopper. Is there any way to animate the multi start points of different curves move to the end along its curve(like trajectories generated by points) and show differernt speeds in different segements( the length beweent points)?
As the picture shows, i have two trajectories generated by points. They have different segments and different speeds.


Points to curve.gh (5.2 KB)

Hi,
I made a simple example in python for you to move a point along a curve.
You can adapt it to your use case

import Rhino.Geometry as rg
import rhinoscriptsyntax as rs
import time

curve = rg.LineCurve(rg.Line(rg.Point3d(0,0,0), rg.Point3d(10,25,0)))
point = rg.Point3d(0,0,0)
speed = 0
point_obj = rs.AddPoint(point)

# move the point along the curve one little step at a time
for t in range(0, 100):
    # based on how many steps have been taken
    parameter = t / 100.0
    point = curve.PointAt(parameter)

    tangent = curve.TangentAt(parameter)

    speed = 1

    # move the Rhino point object to the current point on the curve
    rs.MoveObject(point_obj, point)

    # print the current position and speed of the point
    print("Point at ({}, {}), speed = {}".format(point.X, point.Y, speed))

    # wait for 100ms before moving to the next step
    time.sleep(0.1)

# delete the Rhino point object when the animation is complete
rs.DeleteObject(point_obj)

Another example

def move_point_along_curve(curve, steps, sleep_duration, initial_velocity, gravity, drag_coefficient):
    length = curve.GetLength()
    point_obj = rs.AddPoint(curve.PointAtStart)
    velocity = initial_velocity
    traveled_distance = 0

    rs.EnableRedraw(True)

    for t in range(steps):
        if traveled_distance >= length:
            break

        # Update velocity based on gravity and drag
        velocity -= (gravity + drag_coefficient * velocity) * sleep_duration

        # Calculate the traveled distance based on the current velocity
        traveled_distance += abs(velocity) * sleep_duration  # Make sure the distance is positive

        # Calculate the normalized parameter of the curve based on the traveled distance
        parameter = traveled_distance / length

        # Get the point on the curve corresponding to the parameter value
        point = curve.PointAt(parameter)

        # Move the Rhino point object to the current point on the curve
        rs.MoveObject(point_obj, point)

        print("Point at ({}, {}), speed = {}".format(point.X, point.Y, velocity))

        # Redraw the viewport to see the point moving in real-time
        rs.Redraw()
        time.sleep(sleep_duration)

    rs.DeleteObject(point_obj)
1 Like