From 2b3bcb08773bcbebe983ba28f281896ead336397 Mon Sep 17 00:00:00 2001 From: ringsaturn Date: Sun, 20 Nov 2022 21:19:09 +0800 Subject: [PATCH] prepare init release --- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/README.md b/README.md index d89a092..667dcf0 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,55 @@ Rewrite parts of [tidwall/geometry](https://github.com/tidwall/geometry) to Rust for [ringsaturn/tzf-rs](https://github.com/ringsaturn/tzf-rs). + +```toml +[dependencies] +geometry-rs = { git = "http://github.com/ringsaturn/geometry-rs", tag = "v0.1.0"} +``` + +```rust +use std::vec; + +use geometry_rs; + +fn main() { + let poly = geometry_rs::Polygon::new( + vec![ + geometry_rs::Point { + x: 90.48826291293898, + y: 45.951129815858565, + }, + geometry_rs::Point { + x: 90.48826291293898, + y: 27.99437617512571, + }, + geometry_rs::Point { + x: 122.83201291294, + y: 27.99437617512571, + }, + geometry_rs::Point { + x: 122.83201291294, + y: 45.951129815858565, + }, + geometry_rs::Point { + x: 90.48826291293898, + y: 45.951129815858565, + }, + ], + vec![], + ); + + let p_out = geometry_rs::Point { + x: 130.74216916294148, + y: 37.649011392900306, + }; + + print!("{:?}\n", poly.contains_point(p_out)); + + let p_in = geometry_rs::Point { + x: 99.9804504129416, + y: 39.70716466970461, + }; + print!("{:?}\n", poly.contains_point(p_in)); +} +```