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
mod convert;
use super::*;
#[derive(Debug, Clone)]
pub struct Triangle<T> {
pub vertex: [Point<T>; 3],
}
impl<T> Triangle<T> {
pub fn new<P>(vertex: [P; 3]) -> Self
where
Point<T>: From<P>,
{
let [a, b, c] = vertex;
Self { vertex: [a.into(), b.into(), c.into()] }
}
}
impl<T> Triangle<T>
where
T: Clone + Real,
{
pub fn is_valid(&self) -> bool {
let (ab, ac, _) = self.edges();
ab.is_parallel(&ac)
}
pub fn is_congruent(&self) -> bool {
true
}
pub fn is_isosceles(&self) -> bool {
true
}
pub fn perimeter(&self) -> T {
todo!()
}
pub fn area(&self) -> T {
let det1 = self.vertex[0].x.clone() * self.vertex[1].y.clone() - self.vertex[1].x.clone() * self.vertex[0].y.clone();
let det2 = self.vertex[1].x.clone() * self.vertex[2].y.clone() - self.vertex[2].x.clone() * self.vertex[1].y.clone();
let det3 = self.vertex[2].x.clone() * self.vertex[0].y.clone() - self.vertex[0].x.clone() * self.vertex[2].y.clone();
(det1 + det2 + det3) / two()
}
pub fn inscribed_circle(&self) -> Circle<T> {
todo!()
}
pub fn circumscribed_circle(&self) -> Circle<T> {
Circle::from_3_points(self.vertex[0].clone(), self.vertex[1].clone(), self.vertex[2].clone())
}
#[inline]
fn edges(&self) -> (Vector<T>, Vector<T>, Vector<T>) {
todo!()
}
}