microcad_core/geo2d/
mod.rs

1// Copyright © 2024-2025 The µcad authors <info@ucad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4//! 2D Geometry
5
6mod bounds;
7mod circle;
8mod collection;
9mod geometry;
10mod line;
11mod primitives;
12mod size;
13
14use crate::*;
15
16pub use bounds::*;
17pub use circle::*;
18pub use collection::*;
19use geo::AffineTransform;
20pub use geometry::*;
21pub use line::*;
22pub use primitives::*;
23pub use size::*;
24
25/// Trait to return all points of 2D geometry.
26pub trait FetchPoints2D {
27    /// Returns all points.
28    fn fetch_points_2d(&self) -> Vec<Vec2>;
29}
30
31/// Transformed version of a 2D geometry.
32pub trait Transformed2D<T = Self> {
33    /// Transform from matrix.
34    fn transformed_2d(&self, mat: &Mat3) -> T;
35}
36
37/// Convert a [`Mat3`]` into an affine transform.
38pub(crate) fn mat3_to_affine_transform(mat: &Mat3) -> AffineTransform {
39    geo::AffineTransform::new(mat.x.x, mat.y.x, mat.z.x, mat.x.y, mat.y.y, mat.z.y)
40}