Function dot
Computes the Euclidean dot product of two vectors.
Both vectors use the same storage scalar type.
Returns
The dot product in MetricScalar!T.
Integral components are converted to MetricScalar!T before
multiplication. The operation therefore follows ordinary floating-point
metric arithmetic and does not promise exact integral accumulation.
Floating-point NaN and infinity follow ordinary floating-point arithmetic.
This is a numerical vector operation, not a robust exact predicate.
No allocation is performed.
Complexity
O(1) time and O(1) auxiliary space.
Example
Example computing a vector dot product through the public package API.
import geo;
auto a = Vector2!int(1, 2);
auto b = Vector2!int(3, 4);
static assert(
is(typeof(dot(a, b)) == double)
);
assert(dot(a, b) == 11.0);