Skip to content
DeepForgeby svx
All problems
MediumCalculusca-263

Arc Length Parametrization Check

Problem

A curve is parametrized by arc length when its speed ||dr/dt|| equals 1 everywhere.

Samples of the curve are given as 2D points with matching parameter values; estimate the speed on each segment by the secant length divided by the parameter gap. Given the points and parameters, return True when every speed is within tol (default 1e-6) of 1, and True vacuously for fewer than two points.

Hint

Arc length parametrization travels one unit of distance per unit of parameter.

Test cases

case 1
in: [[[0,0],[1,0],[2,0]],[0,1,2]]
expected: true
case 2
in: [[[0,0],[2,0],[4,0]],[0,1,2]]
expected: false
case 3
in: [[[0,0],[0,1]],[0,2]]
expected: false
case 4
in: [[[0,0],[0,0]],[0,1]]
expected: false
case 5
in: [[[5,5]],[0]]
expected: true
Starter codePython
def is_unit_speed(points, params, tol=1e-6):
    # Your code here
    pass

5 test cases · run your code against them in the editor