# [−][src]Struct obscura::Vec3

```pub struct Vec3 {
pub x: f32,
pub y: f32,
pub z: f32,
}```

Representation of a vector in R3.

## Fields

`x: f32``y: f32``z: f32`

## Methods

### `impl Vec3`[src]

#### `pub fn new(x: f32, y: f32, z: f32) -> Vec3`[src]

Create a new Vec3 with x, y, z as elements.

# Examples

`let x = obscura::Vec3::new(1.0, 1.0, 1.0);`

#### `pub fn one() -> Vec3`[src]

Create a one vector.

# Examples

```let x = obscura::Vec3::new(1.0, 1.0, 1.0);
let y = obscura::Vec3::one();
assert_eq!(x,y);```

#### `pub fn zero() -> Vec3`[src]

Create a zero vector.

# Examples

```let x = obscura::Vec3::new(0.0, 0.0, 0.0);
let y = obscura::Vec3::zero();
assert_eq!(x,y);```

#### `pub fn add(a: &Vec3, b: &Vec3) -> Vec3`[src]

Add two Vec3's and return new Vec3 as result.

# Examples

```let a = obscura::Vec3::new(1.0, 0.0, 0.0);
let b = obscura::Vec3::new(0.0, 1.0, 0.0);
let c = obscura::Vec3::new(1.0, 1.0, 0.0);

assert_eq!(result, c);```

#### `pub fn sub(a: &Vec3, b: &Vec3) -> Vec3`[src]

Subtract a from b and return new Vec3 as result.

# Examples

```let a = obscura::Vec3::new(0.0, 1.0, 0.0);
let b = obscura::Vec3::new(0.0, 1.0, 0.0);
let c = obscura::Vec3::new(0.0, 0.0, 0.0);

let result = obscura::Vec3::sub(&a, &b);
assert_eq!(result, c);```

#### `pub fn dot(a: &Vec3, b: &Vec3) -> f32`[src]

Calcuate dot product (scalar product).

# Examples

```// Create two orthogonal vectors
let a = obscura::Vec3::new(1.0, 0.0, 0.0);
let b = obscura::Vec3::new(0.0, 1.0, 0.0);

// Result of dot product is 0
let result = obscura::Vec3::dot(&a, &b);
assert_eq!(result, 0.0);```

#### `pub fn cross(a: &Vec3, b: &Vec3) -> Vec3`[src]

Calcuate cross product and return new Vec3 as result.

# Examples

```use obscura::Vec3;

// Create two vectors
let a = Vec3::new(1.0, 0.0, 0.0);
let b = Vec3::new(0.0, 1.0, 0.0);

// Result of cross product is orthogonal two both
assert_eq!(
Vec3::cross(&a, &b),
Vec3::new(0.0, 0.0, 1.0)
);```

## Blanket Implementations

### `impl<T> ToOwned for T where    T: Clone, `[src]

#### `type Owned = T`

The resulting type after obtaining ownership.

### `impl<T, U> TryFrom<U> for T where    U: Into<T>, `[src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

### `impl<T, U> TryInto<U> for T where    U: TryFrom<T>, `[src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.