Header menu logo Euclid

Similarity2D Module

For finding 2D object that are similar but not exactly the same. Based on their 2D point clouds. Within one list of points the order does not matter, but each location must exist only once in order to be consider similar within the tolerance. (This module could be extended to work in 3d too)

Types

Type Description

GroupInsideObjectToCheck

A type used inside ObjectToCheck. It represent a group of similar input. The 'category' string is used to only compare groups of the same category. The 'bounding Rectangle' of the points is used as a fast and first check for similarity. Within one 'list of points' the order does not matter, but each location must exist only once in order to be consider similar within the tolerance with another GroupInsideObjectToCheck.

ObjectToCheck

A type to represent on object that shall be compared to other objects. 'extend' (just a 2D point) represents the max value of a bounding Rectangle, min value must be x=0 and y=0. This is used for a very fast initial similarity check. 'groups' (an array of GroupInsideObjectToCheck) must be sorted by 'category' property.

Functions and values

Function or value Description

areSimilar tol a b

Full Usage: areSimilar tol a b

Parameters:
Returns: bool

Takes transformed and pre sorted by category main groups.

tol : float
a : ObjectToCheck
b : ObjectToCheck
Returns: bool

getGrouped (tolerance, items, sims)

Full Usage: getGrouped (tolerance, items, sims)

Parameters:
    tolerance : float
    items : ResizeArray<'T>
    sims : ResizeArray<ObjectToCheck>

Returns: ResizeArray<ResizeArray<'T>>

This will group similar generic items together based on their ObjectToCheck. The list of items and precomputed SimilarityMainGroups must have the same length and correspond to each other at the same index. SimilarityMainGroups is precomputed for better performance.

tolerance : float
items : ResizeArray<'T>
sims : ResizeArray<ObjectToCheck>
Returns: ResizeArray<ResizeArray<'T>>

getSimilarityData ptss

Full Usage: getSimilarityData ptss

Parameters:
    ptss : ResizeArray<string * ResizeArray<Pt>>

Returns: ObjectToCheck

The returned ObjectToCheck will have the subgroups sorted by category and each point will be transformed by the overall bounding Rectangle Min point to 0, 0. Input Position of points does not matter, they will be moved to origin by overall bounding Rectangle over all lists, But any similarity that could be achieved by rotation will not be discovered. The string is used as a unique category identifier.

ptss : ResizeArray<string * ResizeArray<Pt>>
Returns: ObjectToCheck

Type something to start searching.