circle/
lib.rs

1#![allow(non_upper_case_globals)]
2#![allow(mixed_script_confusables)]
3#![deny(missing_docs)]
4#![deny(missing_debug_implementations)]
5#![doc = include_str!("../readme.md")]
6
7mod circle;
8mod ellipse;
9mod extension;
10mod line;
11mod point;
12
13pub use crate::float::{π, Float};
14#[cfg(feature = "serde")]
15use serde::{Deserialize, Serialize};
16
17/// The representation of a ellipse.
18#[derive(Clone, Copy, Debug, PartialEq)]
19#[cfg_attr(feature = "serde", repr(C), derive(Serialize, Deserialize))]
20pub struct Ellipse {
21    a: Float,
22    b: Float,
23    c: Float,
24    d: Float,
25    e: Float,
26    f: Float,
27}
28
29/// The representation of a circle.
30#[derive(Clone, Copy, Debug, PartialEq)]
31#[cfg_attr(feature = "serde", repr(C), derive(Serialize, Deserialize))]
32pub struct Circle {
33    /// Center of the circle.
34    pub center: Point,
35    /// Radius of the circle.
36    pub radius: Float,
37}
38
39/// The representation of a line.
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[cfg_attr(feature = "serde", repr(C), derive(Serialize, Deserialize))]
42pub struct Line {
43    /// Start of the line.
44    pub start: Point,
45    /// End of the line.
46    pub end: Point,
47}
48
49/// The representation of a point.
50#[derive(Clone, Copy, Debug, PartialEq)]
51#[cfg_attr(feature = "serde", repr(C), derive(Serialize, Deserialize))]
52pub struct Point {
53    /// The x-coordinate.
54    pub x: Float,
55    /// The y-coordinate.
56    pub y: Float,
57}
58
59// noinspection NonAsciiCharacters
60#[cfg(feature = "f32")]
61mod float {
62    /// Float Type
63    pub type Float = f32;
64
65    /// constant π
66    pub const π: Float = std::f32::consts::PI;
67}
68
69// noinspection NonAsciiCharacters
70#[cfg(feature = "f64")]
71mod float {
72    /// Float Type
73    pub type Float = f64;
74
75    /// constant π
76    pub const Pi: Float = std::f64::consts::PI;
77}