Files
education-rs-rep/src/console_render/c_math.rs
T
2026-05-11 14:29:27 +03:00

32 lines
571 B
Rust

#[derive(Clone)]
pub struct f2d {
x: f64,
y: f64,
}
impl f2d {
pub fn new(a: f64, b: f64) -> Self {
f2d { x: a, y: b }
}
pub fn def() -> Self {
f2d { x: 0.0, y: 0.0 }
}
//
pub fn len(&self) -> f64 {
self.x * self.x + self.y * self.y
}
pub fn add(&mut self, b: f2d) {
self.x += b.x;
self.y += b.y;
}
pub fn mul(&mut self, b: f2d) {
let x: f64 = self.x * b.x - self.y * b.y;
let y: f64 = self.x * b.y + self.y * b.x;
self.x = x;
self.y = y;
}
}