Struct Delaunay

Source
pub struct Delaunay {
    pub points: Vec<f64>,
    pub point_markers: Vec<i32>,
    pub triangles: Vec<usize>,
    pub neighbors: Option<Vec<i32>>,
    pub edges: Option<Vec<usize>>,
}
Expand description

Delaunay triangulation

Fields§

§points: Vec<f64>

Triangulation vertices as [x0,y0,x1,y1,…]

§point_markers: Vec<i32>

Indices in points.chunks(2), the first 3 indices correspond to the vertices of the 1st triangle, the next 3 to the 2nd triangle, etc…

§triangles: Vec<usize>§neighbors: Option<Vec<i32>>

List of triangles neighbors: indices in triangles.chunks(3) (3 integers per triangle)

§edges: Option<Vec<usize>>

Edges endpoints: indices in points.chunks(2) (2 integers per edge)

Implementations§

Source§

impl Delaunay

Source

pub fn new() -> Self

Creates a new empty Delaunay triangulation

Source

pub fn builder() -> Builder

Returns the Delaunay builder

Source

pub fn n_vertices(&self) -> usize

Returns the number of vertices

Source

pub fn n_triangles(&self) -> usize

Returns the number of Delaunay triangles

Source

pub fn vertex_iter(&self) -> Chunks<'_, f64>

Returns an iterator over the vertices, each item is a vertex (x,y) coordinates

Source

pub fn vertex_iter_mut(&mut self) -> ChunksMut<'_, f64>

Returns an iterator over mutable vertices, each item is a vertex (x,y) coordinates

Source

pub fn vertex_par_iter(&self) -> Chunks<'_, f64>

Returns a parallel iterator over the vertices, each item is a vertex (x,y) coordinates

Source

pub fn triangle_iter(&self) -> Chunks<'_, usize>

Returns an iterator over the triangles, each item is the indices of the vertices in vertex_iter

Source

pub fn triangle_iter_mut(&mut self) -> ChunksMut<'_, usize>

Returns an iterator over mutable triangles, each item is the indices of the vertices in vertex_iter

Source

pub fn triangle_par_iter(&self) -> Chunks<'_, usize>

Returns a parallel iterator over the triangles, each item is the indices of the vertices in vertex_iter

Source

pub fn x(&self) -> Vec<f64>

Gets node x coordinates

Source

pub fn y(&self) -> Vec<f64>

Gets node y coordinates

Source

pub fn triangle_vertex_iter(&self) -> impl Iterator<Item = Vec<(f64, f64)>> + '_

Returns an interator over the triangles, each item is a vector of the 3 (x,y) vertices coordinates

Source

pub fn filter_within_circle( &mut self, radius: f64, origin: Option<(f64, f64)>, ) -> &mut Self

Removes triangles inside a circle of given radius centered on Some(origin)

Source

pub fn triangle_areas(&self) -> Vec<f64>

Returns the triangle areas

Source

pub fn area(&self) -> f64

Returns the area covered by the mesh as the sum of the triangle area

Source

pub fn mesh_area(&self) -> f64

Returns the area covered by the mesh as the sum of the Delaunay triangles area

Source

pub fn average(&self, vertices: &[[f64; 3]], data: &[f64]) -> f64

Source

pub fn average_with<F: Fn(f64) -> f64>( &self, vertices: &[[f64; 3]], data: &[f64], f: F, ) -> f64

Source

pub fn dot(&self, v_a: &[f64], v_b: &[f64]) -> f64

Returns the dot product of two vector a and b sampled on the Delaunay mesh

Source

pub fn is_point_inside(&self, point: &[f64], triangle_id: usize) -> bool

Returns true if a point [x,y] is inside the triangle given by its index (triangle_id) in triangles_iter, otherwise returns false

Source

pub fn which_contains_point(&self, point: &[f64]) -> Option<usize>

Finds the index of the triangle in triangles_iter that contains the given point [x,y]

Source

pub fn point_into_barycentric( &self, point: &[f64], triangle_ids: &[usize], ) -> [f64; 3]

Returns the barycentric coordinates of a point [x,y] with respect to the triangle that contains it

The triangle that contains the point is specified with the indices triangle_ids in vertex_iter of the triangle vertices

Source

pub fn barycentric_interpolation( &self, point: &[f64], val_at_vertices: &[f64], ) -> f64

Linearly interpolates at a given point [x,y], values val_at_vertices at the Delaunay mesh vertices

The linear interpolation is based on the barycentric coordinates of the point

Source

pub fn dump<T: AsRef<Path>>(&self, filename: T) -> Result<(), Box<dyn Error>>

Trait Implementations§

Source§

impl Debug for Delaunay

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Delaunay

Source§

fn default() -> Delaunay

Returns the “default value” for a type. Read more
Source§

impl Display for Delaunay

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for Delaunay

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.