diff options
Diffstat (limited to 'src/math/polygon/mod.rs')
| -rw-r--r-- | src/math/polygon/mod.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/math/polygon/mod.rs b/src/math/polygon/mod.rs index bc145ed..02d8abb 100644 --- a/src/math/polygon/mod.rs +++ b/src/math/polygon/mod.rs @@ -58,13 +58,11 @@ impl<T: Scalar + Copy> Polygon<T> { } /// Like new, but does not perform any validity checks, so be careful when using this function. - pub fn new_unchecked<M>(corners: Vec<Vec2<T>>, t_margin: M) -> Self + pub(crate) fn new_unchecked<M>(corners: Vec<Vec2<T>>, t_margin: M) -> Self where T: RealField + ApproxEq<Margin = M>, M: Copy, { - assert!(Polygon::check_validity(&corners, t_margin).is_ok()); - let corners = if combined_angle(&corners, t_margin) > T::zero() { corners } else { @@ -74,6 +72,12 @@ impl<T: Scalar + Copy> Polygon<T> { Self { corners } } + /// Create a polygon from the sorted vertices. This will create an invalid polygon if the + /// vertices are not sorted so that the edges turn counterclockwise, so use with caution. + pub(crate) fn from_vertices(corners: Vec<Vec2<T>>) -> Self { + Self { corners } + } + /// Checks if a set of corners can be made into a polygon or not. Returns Ok if they can, or /// the reason they cannot in form of a PolygonError. pub fn check_validity<M>(corners: &[Vec2<T>], t_margin: M) -> Result<(), PolygonError<T>> |
