Skip to content

Computing the error should consider the limitation of control points #12

@carlos-adir

Description

@carlos-adir

When fitting a curve into another, the following line is called:

error = np.dot(np.moveaxis(ctrlpoints, 0, -1), np.dot(materror, ctrlpoints))

Basically it's equivalent to

$$\text{error} = C^T \cdot \left[M\right] \cdot C = \sum_i \sum_j C_{i} \cdot M_{ij} \cdot C_{j}$$

This line supposes the control points are numpy.ndarray instances to move the first axis to the last one.
It works well when C has a shape of (n, ) or (n, m), but it breaks for custom control points that supports only linear operations:

  • Adding two points: $C_0 + C_1$
  • Multiplication by scalar: $a \cdot C_0$

The correction is to compute

$$\text{error} = \sum_i \sum_j M_{ij} \langle C_{i}, C_{j} \rangle$$

In python, it would be translated to:

error = sum(sum(matval * (pi @ pj)
            for matval, pj in zip(line, ctrlpoints))
            for line, pj in zip(materror, ctrlpoints))

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions