Новая модель пространства
This commit is contained in:
-17
@@ -4,7 +4,6 @@ use sdl3::pixels::Color;
|
|||||||
use sdl3::render::{FPoint, WindowCanvas};
|
use sdl3::render::{FPoint, WindowCanvas};
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
use std::ops;
|
use std::ops;
|
||||||
use std::ops::Add;
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
const SIZE: u32 = 400;
|
const SIZE: u32 = 400;
|
||||||
@@ -96,19 +95,6 @@ impl Point2D {
|
|||||||
Point2D::new(cos * scale, sin * scale)
|
Point2D::new(cos * scale, sin * scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_polar(p: Point2D) -> Point2D {
|
|
||||||
let len = p.y.hypot(p.x);
|
|
||||||
let cos = p.x / len;
|
|
||||||
let sin = p.y / len;
|
|
||||||
let x = cos.acos();
|
|
||||||
let mut y = sin.asin();
|
|
||||||
let mb_sin = x.sin();
|
|
||||||
if y.signum() != mb_sin.signum() {
|
|
||||||
y = -y;
|
|
||||||
}
|
|
||||||
Point2D::new(x, y)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn to_sdl(&self) -> FPoint {
|
pub fn to_sdl(&self) -> FPoint {
|
||||||
FPoint::new(self.x + SIZE as f32, self.y + SIZE as f32)
|
FPoint::new(self.x + SIZE as f32, self.y + SIZE as f32)
|
||||||
}
|
}
|
||||||
@@ -146,9 +132,6 @@ impl Point2D {
|
|||||||
// canvas.draw_points(&points).unwrap()
|
// canvas.draw_points(&points).unwrap()
|
||||||
canvas.draw_points(&points[..]).unwrap();
|
canvas.draw_points(&points[..]).unwrap();
|
||||||
}
|
}
|
||||||
fn requires_slice<'a, T: Into<&'a [FPoint]>>(arg: T) {
|
|
||||||
let slice: &[FPoint] = arg.into();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ops::AddAssign for Point2D {
|
impl ops::AddAssign for Point2D {
|
||||||
|
|||||||
Reference in New Issue
Block a user