pub struct Rotation3D {
pub roll: f32,
pub pitch: f32,
pub yaw: f32,
}Expand description
Représente les 3 angles de rotation en radians (Roulis, Tangage, Lacet).
Convention : Roll autour de Z, Pitch autour de X, Yaw autour de Y, appliqués dans cet ordre (Roll puis Pitch puis Yaw).
Fields§
§roll: f32§pitch: f32§yaw: f32Implementations§
Source§impl Rotation3D
impl Rotation3D
pub const IDENTITY: Self
Sourcepub fn new(roll: f32, pitch: f32, yaw: f32) -> Self
pub fn new(roll: f32, pitch: f32, yaw: f32) -> Self
Examples found in repository?
examples/orbit_viewer.rs (lines 62-66)
46 fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
47 let ctx = ui.ctx().clone();
48
49 // 1. Simulation physique / télémétrie
50 if !self.paused {
51 let dt = ctx.input(|i| i.stable_dt).min(0.1); // Pas de temps fluide
52 self.time += dt * self.orbit_speed;
53
54 // Orbite circulaire avec oscillation verticale (altitude)
55 self.state.position = [
56 self.time.cos() * self.orbit_radius,
57 (self.time * 1.5).sin() * 0.6,
58 self.time.sin() * self.orbit_radius,
59 ];
60
61 // Attachement d'attitude (Roll, Pitch, Yaw dynamiques)
62 self.state.rotation = Rotation3D::new(
63 (self.time * 2.0).sin() * 0.2, // Léger roulis
64 (self.time * 1.5).cos() * 0.3, // Tangage
65 self.time * 0.5, // Lacet continu
66 );
67
68 // Mise à jour des historiques
69 self.trail.push(self.state.position);
70
71 self.altitude_history.push(self.state.position[1]);
72 if self.altitude_history.len() > 200 {
73 self.altitude_history.remove(0);
74 }
75 }
76
77 // 2. Panneau de contrôle latéral (IHM)
78 egui::Panel::left("control_panel")
79 .resizable(true)
80 .default_size(240.0)
81 .show(ui, |ui| {
82 ui.heading("🛰️ Orbit Viewer");
83 ui.small("Station de sol & Télémétrie");
84 ui.separator();
85
86 // Contrôles de simulation
87 ui.label("Contrôles de l'orbite :");
88 ui.checkbox(&mut self.paused, "Pause simulation");
89 ui.add(egui::Slider::new(&mut self.orbit_speed, 0.1..=3.0).text("Vitesse"));
90 ui.add(egui::Slider::new(&mut self.orbit_radius, 0.5..=4.0).text("Rayon"));
91
92 if ui.button("🗑️ Effacer la trajectoire").clicked() {
93 self.trail.clear();
94 self.altitude_history.clear();
95 }
96
97 ui.separator();
98
99 // Telemetry Data Box
100 ui.label("Données en direct :");
101 egui::Frame::group(ui.style()).show(ui, |ui| {
102 ui.monospace(format!("Pos X: {:+.2} m", self.state.position[0]));
103 ui.monospace(format!("Alt Y: {:+.2} m", self.state.position[1]));
104 ui.monospace(format!("Pos Z: {:+.2} m", self.state.position[2]));
105 ui.separator();
106 ui.monospace(format!("Pitch: {:+.2} rad", self.state.rotation.pitch));
107 ui.monospace(format!("Yaw: {:+.2} rad", self.state.rotation.yaw));
108 });
109
110 ui.separator();
111 ui.collapsing("🖱️ Contrôles Caméra", |ui| {
112 ui.small("• Clic Gauche + Glisser : Orbite");
113 ui.small("• Molette : Zoom");
114 ui.small("• Clic Droit / Molette : Panoramique");
115 });
116 });
117
118 // 3. Zone de rendu 3D
119 egui::CentralPanel::default().show(ui, |ui| {
120 // Calcul préalable du rectangle du graphe pour éviter tout conflit de borrow avec `ui`
121 let avail_rect = ui.available_rect_before_wrap();
122 let chart_rect = egui::Rect::from_min_size(
123 egui::pos2(avail_rect.max.x - 230.0, avail_rect.min.y + 15.0),
124 egui::vec2(215.0, 90.0),
125 );
126
127 self.engine.render(ui, |r| {
128 // Rendu du maillage fil de fer du cube
129 r.draw_mesh(
130 &self.mesh,
131 self.state.position,
132 self.state.rotation,
133 egui::Color32::from_rgb(100, 200, 255),
134 );
135
136 // Repère d'axes XYZ sur l'objet
137 r.draw_axes(self.state.position, self.state.rotation, 1.2);
138
139 // Trajectoire historique
140 r.draw_trail(self.trail.as_slice(), egui::Color32::GOLD);
141
142 // Overlay Graphe 2D de télémétrie (Altitude)
143 r.draw_chart(
144 chart_rect,
145 &self.altitude_history,
146 -1.0, // Min Y
147 1.0, // Max Y
148 egui::Color32::GREEN,
149 );
150 });
151 });
152
153 // Demande le rafraîchissement continu de l'affichage
154 ctx.request_repaint();
155 }Sourcepub fn rotate_point(&self, p: Vec3) -> Vec3
pub fn rotate_point(&self, p: Vec3) -> Vec3
Applique la rotation Roll -> Pitch -> Yaw à un point 3D.
Sourcepub fn compose(&self, other: Rotation3D) -> Rotation3D
pub fn compose(&self, other: Rotation3D) -> Rotation3D
Compose deux rotations (approximation par angles d’Euler cumulés).
Pour une composition rigoureuse, préférer une future implémentation
via quaternions (voir embedded-quaternion-f32).
Trait Implementations§
Source§impl Clone for Rotation3D
impl Clone for Rotation3D
Source§fn clone(&self) -> Rotation3D
fn clone(&self) -> Rotation3D
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Rotation3D
Source§impl Debug for Rotation3D
impl Debug for Rotation3D
Source§impl Default for Rotation3D
impl Default for Rotation3D
Source§fn default() -> Rotation3D
fn default() -> Rotation3D
Returns the “default value” for a type. Read more
Source§impl PartialEq for Rotation3D
impl PartialEq for Rotation3D
impl StructuralPartialEq for Rotation3D
Auto Trait Implementations§
impl Freeze for Rotation3D
impl RefUnwindSafe for Rotation3D
impl Send for Rotation3D
impl Sync for Rotation3D
impl Unpin for Rotation3D
impl UnsafeUnpin for Rotation3D
impl UnwindSafe for Rotation3D
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more