angleBetween method
Implementation
double angleBetween(List<num> other) {
if (length != other.length) {
throw ArgumentError('Vectors must have the same dimensions.');
}
double dotProduct = 0;
double magnitudeA = 0;
double magnitudeB = 0;
for (int i = 0; i < length; i++) {
dotProduct += this[i] * other[i];
magnitudeA += pow(this[i], 2);
magnitudeB += pow(other[i], 2);
}
magnitudeA = sqrt(magnitudeA);
magnitudeB = sqrt(magnitudeB);
return acos(dotProduct / (magnitudeA * magnitudeB)).toDegrees();
}