Skip to main content

buffer_point

Function buffer_point 

Source
pub fn buffer_point<P>(
    center: &P,
    distance: f64,
    strategy: PointStrategy,
) -> Ring<P>
Expand description

Buffer a point by distance, producing the disc (or square) approximation.

Mirrors the point arm of boost::geometry::buffer with a point_circle / point_square strategy (strategies/buffer/buffer_point_circle.hpp).

§Examples

use geometry_cs::Cartesian;
use geometry_model::Point2D;
use geometry_overlay::buffer::{buffer_point, PointStrategy};
use geometry_algorithm::ring_area;

type P = Point2D<f64, Cartesian>;
let disc = buffer_point(&P::new(0.0, 0.0), 1.0, PointStrategy::Circle { points_per_circle: 360 });
// Area of the 360-gon closely approximates π.
assert!((ring_area(&disc).abs() - core::f64::consts::PI).abs() < 1e-3);