Trait libreda_db::prelude::traits::DoubledOrientedArea[][src]

pub trait DoubledOrientedArea<T> where
    T: CoordinateType
{ pub fn area_doubled_oriented(&self) -> T; }

Calculate the doubled oriented area of a geometry. Using the doubled area allows to compute the area without using fractions. This is especially helpful when computing in integer coordinates.

Required methods

pub fn area_doubled_oriented(&self) -> T[src]

Calculate doubled oriented area of this geometry. Using the doubled area allows to compute the area without using fractions.

Loading content...

Implementations

impl<T> dyn DoubledOrientedArea<T> + 'static where
    T: CoordinateType + NumCast
[src]

pub fn area<F>(&self) -> F where
    F: NumCast + Float
[src]

Compute the area of a geometrical shape by first computing doubled oriented area and then taking absolute value of the half.

Implementors

impl<T> DoubledOrientedArea<T> for Geometry<T> where
    T: CoordinateType + NumCast
[src]

pub fn area_doubled_oriented(&self) -> T[src]

Area calculation.

impl<T> DoubledOrientedArea<T> for Polygon<T> where
    T: CoordinateType
[src]

pub fn area_doubled_oriented(&self) -> T[src]

Calculates the doubled oriented area.

Using doubled area allows to compute in the integers because the area of a polygon with integer coordinates is either integer or half-integer.

The area will be positive if the vertices are listed counter-clockwise, negative otherwise.

Complexity: O(n)

Examples

use iron_shapes::polygon::{Polygon, DoubledOrientedArea};
let coords = vec![(0, 0), (3, 0), (3, 1)];

let poly = Polygon::new(coords);

assert_eq!(poly.area_doubled_oriented(), 3);

impl<T> DoubledOrientedArea<T> for Rect<T> where
    T: CoordinateType
[src]

pub fn area_doubled_oriented(&self) -> T[src]

Calculate doubled oriented area of rectangle.

impl<T> DoubledOrientedArea<T> for SimplePolygon<T> where
    T: CoordinateType
[src]

pub fn area_doubled_oriented(&self) -> T[src]

Calculates the doubled oriented area.

Using doubled area allows to compute in the integers because the area of a polygon with integer coordinates is either integer or half-integer.

The area will be positive if the vertices are listed counter-clockwise, negative otherwise.

Complexity: O(n)

Examples

use iron_shapes::traits::DoubledOrientedArea;
use iron_shapes::simple_polygon::SimplePolygon;
let coords = vec![(0, 0), (3, 0), (3, 1)];

let poly = SimplePolygon::from(coords);

assert_eq!(poly.area_doubled_oriented(), 3);

impl<T> DoubledOrientedArea<T> for SimpleRPolygon<T> where
    T: CoordinateType
[src]

pub fn area_doubled_oriented(&self) -> T[src]

Calculates the doubled oriented area.

Using doubled area allows to compute in the integers because the area of a polygon with integer coordinates is either integer or half-integer.

The area will be positive if the vertices are listed counter-clockwise, negative otherwise.

Complexity: O(n)

Examples

use iron_shapes::traits::DoubledOrientedArea;
use iron_shapes::simple_rpolygon::SimpleRPolygon;
let coords = vec![(0, 0), (1, 0), (1, 1), (0, 1)];

let poly = SimpleRPolygon::try_new(coords).unwrap();

assert_eq!(poly.area_doubled_oriented(), 2);
Loading content...