# I am looking for a function in order to measure points misalignment

The points are in the euclidean plane, let $\mathbb{P}$ be the set containing all the finite sets of $\mathbb{R}^2$ points.

I am looking for a function $m : \mathbb{P} \to \mathbb{R}^+$ in order to measure misalignment :

• If $P \in \mathbb{P}$ contains 3 aligned points then $m(P)=0$
• If $P \in \mathbb{P}$ doesn't contain 3 aligned points then $m(P)>0$
• $m$ continuous according to a shifting of the points (not fully defined)
• Bonus : $m$ should be easy to compute for small inputs.

My only idea is to take the minimum of the hausdorff distance (or any other distance) between the input and any set containing 3 aligned points. But it's not easy to compute, even for small examples.

For three points $A (x_0,y_0),B(x_1,y_2), C(x_2,y_2)$ you can define $$f(A,B,C)=|\det\begin{bmatrix} 1 & 1 & 1 \\ x_0 &x_1 &x_2 \\ y_0 &y_1 &y_2 \end{bmatrix} |$$ where the outside is absolute value. Then $A,B, C$ are colinear if and only if $f(A,B,C)=0$.
Next, for all sets $P \subset \mathbb P$ of at least three points you can define $$m(P) = \min_{ \{A,B,C \} \subset P } f(,A,B,C)$$
You have the freedom to define $m(P)$ any way you like for 1 and 2 points subsets. [you can take it constant for example].