GithubHelp home page GithubHelp logo

simple-geom's Introduction

simple-geom

Rust Library with simple plane geometry

Provided Classes

Supported operations

Point2D

pub fn add(&self, v: &Vector2D) -> Self; /** return the sum of point & vector **/
pub fn sub(&self, p0: &Point2D) -> Vector2D; /** return the vector difference between two points **/
pub fn to_vec(&self) -> Vector2D; /** transform point to radius-vector; the same as difference between point and origin **/
pub fn distance_to(&self, p: &Point2D) -> f64;  /** return the distance between points **/

Vector2D

pub fn len(&self) -> f64;  /** return the length of vector **/
pub fn add(&self, v: &Vector2D) -> Self;  /** return the sum of vectors **/
pub fn add_mut(&mut self, v: &Vector2D) -> &Self;  /** mutably add second vector to the given **/
pub fn kmul(&self, k: f64) -> Self;  /** return scaled by k vector **/
pub fn dot(&self, v: &Vector2D) -> f64;  /** return dot product result for the vectors **/
pub fn cross(&self, v: &Vector2D) -> f64;  /** return cross product result for the 2d vectors **/
pub fn unit(&self) -> Option<Self>;  /** return scaled to the lenght=1 vector if possible **/
pub fn perpendicular(&self) -> Self;  /** return vector perpendicular to the given one **/

Segment2D

pub fn intersect_segment(&self, o: &Segment2D) -> SegmentIntersection; /** return the intersection relation (with intersection point if needed) for 2 segments **/
pub fn intersect_line(&self, l: &Line2D) -> SegmentIntersection;  /** return the intersection relation (with intersection point if needed) for given segment and the line **/

Line2D

pub fn point_relation(&self, p: &Point2D) -> PointLineRelation;  /** check either point lies on the given line **/
pub fn segment_relation(&self, s: &Segment2D) -> SegmentLineRelation;  /** check the way which segment relates to the given line (Intersects, Left, LeftTouch, Right, RightTouch, OnLine) **/

Polygon2D

pub fn len(&self) -> usize;  /** return the number of segments for the given polygon **/
pub fn points(&self) -> impl Iterator<Item = Point2D> + '_;  /** iterate over the vertices of the given polygon **/
pub fn intersect_with_semiplane(&self, l: &Line2D, left_semiplane: bool) -> Option<Polygon2D>;  /** return the intersection of polygon and semiplane **/
pub fn intersect_with_semiplane_mut(&mut self, l: &Line2D, less_mode: bool) -> bool;  /** mutable version of polygon and semiplane intersection **/
pub fn skip_short_edge(&self, tol: f64) -> Self;  /** prune the polygon by removing too small edges (by given tolerance) **/

simple-geom's People

Contributors

heni avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.