A robot-orientation analysis can give every vector pair the same explicit weight and still let one pair dominate the fitted rotation. If the input vectors have different lengths, their contributions to a Cartesian residual objective can differ before any weight array is considered.

An original two-pair example isolates that effect. The vectors are invented, dimensionless inputs in a common three-dimensional coordinate convention. They are not sensor observations or a claim about a calibrated robot. The comparison changes lengths while preserving every input direction.

Define the direction of the fitted transformation

Let target vectors a be [[1,0,0],[0,1,0]]. Let source vectors b be [[1,0,0],[sqrt(3)/2,1/2,0]]. All four are initially unit vectors in the xy plane. The first source-target pair prefers zero rotation about positive z. The second prefers a positive 60-degree rotation, because its source lies at 30 degrees and its target at 90 degrees.

SciPy's align_vectors returns a rotation that maps b toward a and minimizes a weighted squared-vector-distance objective. Its documentation explicitly identifies vector length as an implicit influence on the fit [1]. We use weights [1,1] throughout the initial comparison.

import numpy as np

from scipy.spatial.transform import Rotation as R

a = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]])

b = np.array([[1.0, 0.0, 0.0],

[np.sqrt(3)/2, 0.5, 0.0]])

unit_fit, unit_rssd = R.align_vectors(a, b, weights=[1, 1])

assert np.allclose(unit_fit.as_rotvec()[:2], 0)

assert np.isclose(np.rad2deg(unit_fit.as_rotvec()[2]), 30)

The fitted rotation is 30 degrees about positive z. After rotation, the source directions lie at 30 and 60 degrees, leaving equal 30-degree discrepancies from their respective targets. The two inconsistent pair preferences cannot both be satisfied exactly by one rotation.

Scale one pair without changing its directions

Multiply the first row of both a and b by four. The first pair now contains two length-four vectors; the second remains a pair of unit vectors. Keep the explicit weights at [1,1].

scaled_a, scaled_b = a.copy(), b.copy()

scaled_a[0] *= 4

scaled_b[0] *= 4

length_fit, length_rssd = R.align_vectors(

scaled_a, scaled_b, weights=[1, 1])

angle = np.rad2deg(length_fit.as_rotvec()[2])

assert np.isclose(angle, 3.004491598883079)

The fitted angle shifts from 30 degrees to approximately 3.004492 degrees. That shift favors the first pair's zero-rotation preference. No row was duplicated, no explicit weight changed, and neither vector direction changed.

The executed fixture used SciPy 1.18.1, NumPy 2.5.2, and Python 3.14.7. Both cited SciPy reference pages were labeled 1.18.0. The returned rotations had negligible x and y rotation-vector components in the local checks, allowing the planar angle comparison shown here.

Derive the factor of sixteen

For a planar candidate angle theta, the first scaled pair contributes 16 times its original squared residual because both vectors were multiplied by four. The second contribution is unchanged. With the one-half convention in the loss, the resulting expression is:

L(theta) = 17 - 16*cos(theta) - cos(theta - 60 degrees)

Maximizing the subtracted cosine combination gives atan2(sin(60 degrees),16+cos(60 degrees)). Its value is approximately 3.004492 degrees, matching the library result. Trigonometric calculations must use a consistent angle convention; the accompanying numerical fixture converts the final radian value to degrees.

Calling align_vectors on the original unit inputs with explicit weights [16,1] produces the same rotation matrix as scaling both vectors of the first pair by four. This equivalence holds for the stated transformation of the pair. Scaling only one member would not multiply the entire pair residual by sixteen.

Normalize only when that is the intended model

Normalize each row of scaled_a and scaled_b independently to unit length and repeat the fit with weights [1,1]. The result returns to 30 degrees. That calculation gives the two direction pairs the same explicit role in the unit-vector objective.

a_unit = scaled_a / np.linalg.norm(scaled_a, axis=1)[:, None]

b_unit = scaled_b / np.linalg.norm(scaled_b, axis=1)[:, None]

direction_fit, _ = R.align_vectors(a_unit, b_unit, weights=[1, 1])

assert np.allclose(direction_fit.as_matrix(), unit_fit.as_matrix())

Normalization changes the question when lengths carry meaningful information. It should therefore be a declared modeling choice, not a hidden preprocessing step applied merely because two results disagree. A direction-only data contract also needs a rule for zero-length or invalid vectors before division; this fixture contains neither.

Distinguish a shared scale from a changed relative scale

Multiplying every vector in both arrays by four preserves the 30-degree rotation. Every residual term receives the same factor of sixteen, so the optimizer is unchanged. The reported root sum squared distance, however, increases by four.

In the local calculation the unit-input rssd is approximately 0.732051. Uniformly scaled inputs give approximately 2.928203. These values show why a residual comparison needs the vector units and preprocessing history even when the fitted orientation agrees.

The first-pair-only scaling produces rssd approximately 0.977024. Comparing it directly with the original rssd does not establish that the robot orientation estimate became better or worse: the data representation and objective contributions changed.

Recompute the residual in the declared direction

Apply the returned rotation to scaled_b, then subtract from scaled_a. SciPy's apply reference documents this vector operation and its matrix equivalent [2]. The norm over all components of that residual array reproduces length_rssd in the fixture:

residual = scaled_a - length_fit.apply(scaled_b)

assert np.isclose(np.linalg.norm(residual), length_rssd)

A separate single-pair check uses target [3,0,0] and source [1,0,0]. Their directions already agree, yet the returned rssd is 2 because rotation cannot change length. Thus this residual is not, by itself, an angular error measurement.

For an auditable direction fit, retain pair identities, transformation direction, original row norms, normalization policy, explicit weights, and the exact residual definition. The central comparison is reproducible: equal explicit weights yield 30 degrees for unit pairs and about 3 degrees after one pair's lengths change. Recording those inputs makes the change explainable without attributing it to sensor noise or an unexplained solver failure.

Sources

[1] SciPy, Rotation.align_vectors: https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.align_vectors.html

[2] SciPy, Rotation.apply: https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.apply.html