Struct linal::vec2::Vec2
[−]
[src]
pub struct Vec2 { pub x: f64, pub y: f64, }
2D vector in cartesian coordinates
Fields
x: f64
component of vector
y: f64
component of vector
Methods
impl Vec2
[src]
fn new<I: Into<f64>>(x: I, y: I) -> Vec2
Constructs a new Vec2
.
fn from_polar<I: Into<f64>>(r: I, theta: I) -> Vec2
Constructs a new Vec2
from polar coordinates $(r, \theta)$.
fn zero() -> Vec2
Create a zero Vec2
fn dot(self, rhs: Vec2) -> f64
Scalar product
fn cross(self) -> Vec2
Orthogonal vector
fn area(self, rhs: Vec2) -> f64
Area of parallelogramm
fn len(self) -> f64
Vector length
fn ort(self) -> Vec2
Unary vector, co-directed with given
fn sqr(self) -> Vec2
Squares of the vector coordinates
fn sqrt(self) -> Vec2
Square root of vector coordinates
fn dual_basis(basis: (Vec2, Vec2)) -> (Vec2, Vec2)
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]
impl Clone for Vec2
[src]
fn clone(&self) -> Vec2
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Copy for Vec2
[src]
impl Add for Vec2
[src]
type Output = Self
The resulting type after applying the +
operator
fn add(self, _rhs: Self) -> Self
The method for the +
operator
impl Sub for Vec2
[src]
type Output = Self
The resulting type after applying the -
operator
fn sub(self, _rhs: Self) -> Self
The method for the -
operator
impl Mul for Vec2
[src]
type Output = Self
The resulting type after applying the *
operator
fn mul(self, _rhs: Vec2) -> Vec2
The method for the *
operator
impl<I: Into<f64>> Mul<I> for Vec2
[src]
type Output = Self
The resulting type after applying the *
operator
fn mul(self, _rhs: I) -> Vec2
The method for the *
operator
impl<I: Into<f64>> Div<I> for Vec2
[src]
type Output = Self
The resulting type after applying the /
operator
fn div(self, _rhs: I) -> Vec2
The method for the /
operator
impl Neg for Vec2
[src]
type Output = Self
The resulting type after applying the -
operator
fn neg(self) -> Self
The method for the unary -
operator
impl PartialEq for Vec2
[src]
fn eq(&self, other: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.