[][src]Struct pbrt::core::geometry::Point2

pub struct Point2<T> where
    T: Number
{ pub x: T, pub y: T, }

Generic type for any 2D point.

Fields

x: T

The x coordinate of this point.

y: T

The y coordinate of this point.

Methods

impl<T> Point2<T> where
    T: Number
[src]

pub fn min(p1: Point2<T>, p2: Point2<T>) -> Point2<T>[src]

Create a new Point2 with the min x and y values from p1 & p2.

Examples

use pbrt::core::geometry::Point2i;

let p1 = Point2i::from([2, 8]);
let p2 = Point2i::from([7, 3]);
assert_eq!(Point2i::min(p1, p2), Point2i::from([2, 3]));

pub fn max(p1: Point2<T>, p2: Point2<T>) -> Point2<T>[src]

Create a new Point2 with the max x and y values from p1 & p2.

Examples

use pbrt::core::geometry::Point2i;

let p1 = Point2i::from([2, 8]);
let p2 = Point2i::from([7, 3]);
assert_eq!(Point2i::max(p1, p2), Point2i::from([7, 8]));

Trait Implementations

impl<T> Add<Point2<T>> for Point2<T> where
    T: Number
[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, rhs: Self) -> Self::Output[src]

Implement + for Point2

Examples

use pbrt::core::geometry::Point2i;

let p1: Point2i = [2, 3].into();
let p2: Point2i = [4, 5].into();
assert_eq!(p2 + p1, [6, 8].into());

use pbrt::core::geometry::Point2f;

let p1: Point2f = [2., 3.].into();
let p2: Point2f = [4., 5.].into();
assert_eq!(p2 + p1, [6., 8.].into());

impl<T> Add<Vector2<T>> for Point2<T> where
    T: Number
[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, rhs: Vector2<T>) -> Self::Output[src]

Implement + for Point2 + Vector2

Examples

use pbrt::core::geometry::Point2i;
use pbrt::core::geometry::Vector2i;

let p1: Point2i = [4, 5].into();
let v1: Vector2i = [2, 3].into();
assert_eq!(p1 + v1, Point2i::from([6, 8]));

use pbrt::core::geometry::Point2f;
use pbrt::core::geometry::Vector2f;

let p1: Point2f = [4., 5.].into();
let v1: Vector2f = [2., 3.].into();
assert_eq!(p1 + v1, Point2f::from([6., 8.]));

impl<T: Clone> Clone for Point2<T> where
    T: Number
[src]

impl<T: Copy> Copy for Point2<T> where
    T: Number
[src]

impl<T: Debug> Debug for Point2<T> where
    T: Number
[src]

impl<T: Default> Default for Point2<T> where
    T: Number
[src]

impl<T> Display for Point2<T> where
    T: Number
[src]

impl<T> Div<T> for Point2<T> where
    T: Number
[src]

type Output = Self

The resulting type after applying the / operator.

fn div(self, rhs: T) -> Self::Output[src]

Implement / for Point2 / T

Examples

use pbrt::core::geometry::Point2i;

let p: Point2i = [8, 16].into();
assert_eq!(p / 2, [4, 8].into());

use pbrt::core::geometry::Point2f;

let p: Point2f = [8., 16.].into();
assert_eq!(p / 2., [4., 8.].into());

impl<T> From<[T; 2]> for Point2<T> where
    T: Number
[src]

impl<T> From<(T, T)> for Point2<T> where
    T: Number
[src]

impl From<Point2<f32>> for Point2i[src]

impl From<Point2<isize>> for Point2f[src]

impl<T> Mul<T> for Point2<T> where
    T: Number
[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, rhs: T) -> Self::Output[src]

Implement * for Point2 * T

Examples

use pbrt::core::geometry::Point2i;

let p: Point2i = [8, 16].into();
assert_eq!(p * 2, [16, 32].into());

use pbrt::core::geometry::Point2f;

let p: Point2f = [8., 16.].into();
assert_eq!(p * 2., [16., 32.].into());

impl<T: PartialEq> PartialEq<Point2<T>> for Point2<T> where
    T: Number
[src]

impl<T> StructuralPartialEq for Point2<T> where
    T: Number
[src]

impl<T> Sub<Point2<T>> for Point2<T> where
    T: Number
[src]

type Output = Vector2<T>

The resulting type after applying the - operator.

fn sub(self, rhs: Self) -> Self::Output[src]

Implement - for Point2 - Point2

Mathematically a point minus a point is a vector, and a point minus a vector is a point.

Examples

use pbrt::core::geometry::Point2i;

let p1: Point2i = [2, 3].into();
let p2: Point2i = [4, 5].into();
assert_eq!(p2 - p1, [2, 2].into());

use pbrt::core::geometry::Point2f;

let p1: Point2f = [2., 3.].into();
let p2: Point2f = [4., 5.].into();
assert_eq!(p2 - p1, [2., 2.].into());

impl<T> Sub<Vector2<T>> for Point2<T> where
    T: Number
[src]

type Output = Self

The resulting type after applying the - operator.

fn sub(self, rhs: Vector2<T>) -> Self::Output[src]

Implement - for Point2 - Vector2

Mathematically a point minus a point is a vector, and a point minus a vector is a point.

Examples

use pbrt::core::geometry::Point2i;
use pbrt::core::geometry::Vector2i;

let p1: Point2i = [4, 5].into();
let v1: Vector2i = [2, 3].into();
assert_eq!(p1 - v1, Point2i::from([2, 2]));

use pbrt::core::geometry::Point2f;
use pbrt::core::geometry::Vector2f;

let p1: Point2f = [4., 5.].into();
let v1: Vector2f = [2., 3.].into();
assert_eq!(p1 - v1, Point2f::from([2., 2.]));

Auto Trait Implementations

impl<T> RefUnwindSafe for Point2<T> where
    T: RefUnwindSafe

impl<T> Send for Point2<T> where
    T: Send

impl<T> Sync for Point2<T> where
    T: Sync

impl<T> Unpin for Point2<T> where
    T: Unpin

impl<T> UnwindSafe for Point2<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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.