Math module

dot_product

procedure · 3 overloadsSource

The dot product of two vectors (or two quaternions), the sum of the products of matching components. For unit vectors it is the cosine of the angle between them. Also spelled dot.

ExampleOpen in playground ↗
assert(dot_product(xyz(1, 2, 3), xyz(4, 5, 6)) == 32);
assert(dot(xy(1, 0), xy(0, 1)) == 0);
dot_product :: (a: Vector2, b: Vector2) -> float

The dot product of a and b.

Parameters

a: Vector2
the first vector.
b: Vector2
the second vector.

Returns

float
dot_product :: (a: Vector3, b: Vector3) -> float

The dot product of a and b.

Parameters

a: Vector3
the first vector.
b: Vector3
the second vector.

Returns

float
dot_product :: (a: Vector4, b: Vector4) -> float

The dot product of a and b.

Parameters

a: Vector4
the first vector.
b: Vector4
the second vector.

Returns

float

See also