aboutsummaryrefslogtreecommitdiff
path: root/src/math/surface.rs
blob: ab1c703a799390865f3a47de0b43ab2ff10308dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! Surfaces, which are areas at a certain position in a vector space.

use super::{LineSegment, Polygon, Rect, Vec2};
use nalgebra::Scalar;

/// Trait that describes an area in the vector space on the field of T
pub trait Surface<T: Scalar + Copy> {
    /// Checks if a point lies on this surface.
    fn contains_point(&self, point: &Vec2<T>) -> bool;

    /// Checks if a line segment is entirely contained by this surface.
    fn contains_line_segment(&self, line_segment: &LineSegment<T>) -> bool;

    /// Checks if a rectangle is entirely contained inside this surface.
    fn contains_rect(&self, rect: &Rect<T>) -> bool;

    /// Checks if a polygon is contained wholly by this surface.
    fn contains_polygon(&self, polygon: &Polygon<T>) -> bool;

    /// Checks if this surface is contained by the rect in it's entirety. Think of it as the reverse
    /// operation for contains_... on a rectangle.
    fn is_inside_rect(&self, rect: &Rect<T>) -> bool;
}