1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use super::*;
use crate::elements::polygon_like::Polyline;
#[allow(unused_variables)]
impl<T> Ellipse<T> {
pub fn new<P>(center: P, radius: (T, T), angle: T) -> Self
where
P: Into<Point<T>>,
{
Self { center: center.into(), radius, angle }
}
pub fn from_coefficient(a: T, b: T, c: T, d: T, e: T, f: T) -> Self {
todo!()
}
pub fn from_5_points(p1: Point<T>, p2: Point<T>, p3: Point<T>, p4: Point<T>, p5: Point<T>) {}
}
impl<T> Ellipse<T>
where
T: Zero + PartialEq,
{
pub fn is_horizontal(&self) -> bool {
self.angle == T::zero()
}
}
impl<T> Ellipse<T>
where
T: Real + Pow<u32, Output = T>,
{
pub fn major_axis(&self) -> &T {
&self.radius.0
}
pub fn minor_axis(&self) -> &T {
&self.radius.1
}
pub fn homogeneous(&self) -> (T, T, T, T, T, T) {
todo!()
}
pub fn major_delta(&self) -> T {
let (a, b, c, d, e, f) = self.homogeneous();
a * c * f + two::<T>() * b * d * e - a * e * e - c * d * d - f * b * b
}
pub fn minor_delta(&self) -> T {
let (a, b, c, _, _, _) = self.homogeneous();
a * c - b.pow(2)
}
}
impl<T> Ellipse<T> {
pub fn approx_polygon(self) -> Polygon<T> {
todo!()
}
pub fn approx_polyline(self) -> Polyline<T> {
todo!()
}
}