Struct linal::vec2::Vec2 [] [src]

pub struct Vec2 {
    pub x: f64,
    pub y: f64,
}

2D vector in cartesian coordinates

Fields

component of vector

component of vector

Methods

impl Vec2
[src]

Constructs a new Vec2.

Constructs a new Vec2 from polar coordinates $(r, \theta)$.

Create a zero Vec2

Scalar product

Orthogonal vector

Area of parallelogramm

Vector length

Unary vector, co-directed with given

Squares of the vector coordinates

Square root of vector coordinates

Constructs dual basis for given.

Dual basis $(\vec{b}_1, \vec{b}_2)$ for basis $(\vec{a}_1, \vec{a}_2)$ satisfies relation $$\vec{a}_i \cdot \vec{b}_j = \delta_{ij}$$

Example

use linal::Vec2;

let a1 = Vec2::new(2, 0);
let a2 = Vec2::new(3, 4);

let (b1, b2) = Vec2::dual_basis((a1, a2));
assert_eq!(b1, Vec2::new(0.5, -0.375));
assert_eq!(b2, Vec2::new(0.0, 0.25));

Trait Implementations

impl Debug for Vec2
[src]

Formats the value using the given formatter.

impl Clone for Vec2
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for Vec2
[src]

impl Add for Vec2
[src]

The resulting type after applying the + operator

The method for the + operator

impl Sub for Vec2
[src]

The resulting type after applying the - operator

The method for the - operator

impl Mul for Vec2
[src]

The resulting type after applying the * operator

The method for the * operator

impl<I: Into<f64>> Mul<I> for Vec2
[src]

The resulting type after applying the * operator

The method for the * operator

impl<I: Into<f64>> Div<I> for Vec2
[src]

The resulting type after applying the / operator

The method for the / operator

impl Neg for Vec2
[src]

The resulting type after applying the - operator

The method for the unary - operator

impl PartialEq for Vec2
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Display for Vec2
[src]

Formats the value using the given formatter. Read more

impl FromStr for Vec2
[src]

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more