API Reference / cosineSimilarity · function
Function: cosineSimilarity()
function cosineSimilarity(a, b): number;
Cosine similarity of two feature vectors, in [-1, 1]. For vectors from
chartFeatures this is a weighted mean of cos(Δlongitude) per body:
1 when the configurations coincide, falling off as bodies diverge.
Parameters
| Parameter | Type | Description |
|---|---|---|
a | number[] | First feature vector. |
b | number[] | Second feature vector (compared over the shorter length). |
Returns
number
Similarity in [-1, 1]; 0 if either vector is all zeros.