Skip to main content

dot

Function dot 

Source
pub const fn dot(left: Vector2, right: Vector2) -> f64
Expand description

Returns the dot product of two vectors.

Examples found in repository?
examples/basic_usage.rs (line 8)
3fn main() -> Result<(), use_linear::LinearError> {
4    let vector = Vector2::new(3.0, 4.0);
5    let basis = Matrix2::new(2.0, 1.0, 5.0, 3.0);
6    let rhs = Vector2::new(1.0, 2.0);
7
8    assert!((dot(vector, Vector2::new(-2.0, 1.0)) + 2.0).abs() < 1.0e-12);
9    assert!((vector.magnitude() - 5.0).abs() < 1.0e-12);
10    assert_eq!(
11        basis.mul_vector(Vector2::new(1.0, -1.0)),
12        Vector2::new(1.0, 2.0)
13    );
14    assert_eq!(basis * Matrix2::identity(), basis);
15    assert_eq!(solve_2x2(basis, rhs)?, Vector2::new(1.0, -1.0));
16
17    Ok(())
18}