PIXELBANKv9.1.0
Menu

You are given two sets of corresponding 2D points and need to compute the alignment error (sum of squared distances between corresponding points).

After aligning point sets (e.g., by centering at origin), the alignment error measures how well they match:

E=∑i=1n∥pi−qi∥2=∑i=1n[(px,i−qx,i)2+(py,i−qy,i)2]E = \sum_{i=1}^{n} \|p_i - q_i\|^2 = \sum_{i=1}^{n} [(p_{x,i} - q_{x,i})^2 + (p_{y,i} - q_{y,i})^2]

This is used in:

  • Procrustes analysis for shape matching
  • ICP convergence checking
  • Evaluating transformation quality

Lower error means better alignment.

Example:

Input:
points1 = [(0, 0), (1, 0)]
points2 = [(0, 0), (1, 0.1)]
Output:
0.01
Reasoning:

Computing squared distances for each pair:

Pair 1: (0,0) ↔ (0,0)

  • dx = 0 - 0 = 0
  • dy = 0 - 0 = 0
  • squared_dist = 0² + 0² = 0

Pair 2: (1,0) ↔ (1,0.1)

  • dx = 1 - 1 = 0
  • dy = 0 - 0.1 = -0.1
  • squared_dist = 0² + (-0.1)² = 0.01

Total error = 0 + 0.01 = 0.01

The small error indicates the point sets are nearly identical.

Constraints:

  • points1 and points2 are lists of corresponding (x, y) points of same length
  • Each point in points1 corresponds to the same-indexed point in points2
  • Return total squared error rounded to 4 decimal places
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.