1use crate::Vec3;
2use crate::Etype;
3
4
5
6#[derive(Clone, Debug)]
13pub struct Point {
14 pub position: Vec3,
15 pub direction: Vec3,
16 pub area: f32,
17 pub gravity: f32,
18 pub eclipse: Etype,
19 pub flux: f32,
20}
21
22impl Point {
23
24 pub fn new(position: Vec3, direction: Vec3, area: f64, gravity: f64, eclipse: Etype) -> Self {
28 Self {
29 position,
30 direction,
31 area: area as f32,
32 gravity: gravity as f32,
33 eclipse,
34 flux: 0.0,
35 }
36 }
37 pub fn set_flux(&mut self, flux: f32) -> () {
41 self.flux = flux;
42 }
43
44 pub fn is_visible(&self, phase: f64) -> bool {
49 let phi: f64 = phase - phase.floor();
50 for &(p1, p2) in &self.eclipse {
51 if (phi >= p1 && phi <= p2) || phi <= p2 - 1.0 {
52 return false
53 }
54 }
55 true
56 }
57}
58
59impl Default for Point {
60 fn default() -> Self {
61 Self::new(
62 Vec3::new(0.0, 0.0, 0.0),
63 Vec3::new(0.0, 0.0, 0.0),
64 0.0,
65 0.0,
66 vec![(0.0, 0.0)],
67 )
68 }
69}