From 83c887adff4653836bd77ea6b5dd01af8e6955ae Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 17 Feb 2023 22:15:24 +0800 Subject: [PATCH] update few --- README.md | 19 ++-- configs/main.toml | 4 +- docs/README-en.md | 18 ++-- libs/Difficult_Rocket_rs/src/Cargo.toml | 3 + libs/Difficult_Rocket_rs/src/src/types.rs | 124 +++++++++++++++++++++- 5 files changed, 151 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 5c074bf..c803392 100644 --- a/README.md +++ b/README.md @@ -64,13 +64,18 @@ ## 感谢 -- [pyglet](https://github.com/pyglet/pyglet) : GUI 和画面渲染 -- `tomlkit` / `rtoml` : toml 解析器 -- `xmltodict`: xml 与 dict 转换器 -- `pyperclip`: 剪贴板! -- [@Rayawa](https://github.com/Rayawa) : 文档矫正 & 翻译部分 lang -- [@rouxiao-you](https://github.com/ruoxiao-you) : 翻译 lang -- [@Billchyi](https://github.com/Billchyi) : 文档矫正 +- 开源项目 + - [pyglet](https://github.com/pyglet/pyglet) : GUI 和画面渲染 + - `tomlkit` / `rtoml` : toml 解析器 + - `xmltodict`: xml 与 dict 转换器 + - `pyperclip`: 剪贴板! + - `rapier2d`: 物理模拟引擎 + +- 主要贡献者 + - [@Rayawa](https://github.com/Rayawa) : 文档矫正 & 翻译部分 lang + - [@rouxiao-you](https://github.com/ruoxiao-you) : 翻译 lang + - [@Billchyi](https://github.com/Billchyi) : 文档矫正 + - [@msdn]() ## 相关链接 diff --git a/configs/main.toml b/configs/main.toml index 691937e..f487571 100644 --- a/configs/main.toml +++ b/configs/main.toml @@ -8,8 +8,8 @@ fonts_folder = "libs/fonts" [window] style = "None" -width = 1242 -height = 836 +width = 1802 +height = 1211 visible = true gui_scale = 1 caption = "Difficult Rocket v{DR_version}|DR_rs v{DR_Rust_get_version}" diff --git a/docs/README-en.md b/docs/README-en.md index abf5e8c..f5fe3d3 100644 --- a/docs/README-en.md +++ b/docs/README-en.md @@ -64,13 +64,17 @@ ## thanks to -- [pyglet](https://github.com/pyglet/pyglet): GUI and graphics -- `tomlkit` / `rtoml` toml parser -- `xmltodict`: translate data between xml and dict -- `pyperclip`: paste board! -- [@Rayawa](https://github.com/Rayawa) : check mistake in docs & some translates -- [@rouxiao-you](https://github.com/ruoxiao-you) : translate chinese to English -- [@Billchyi](https://github.com/Billchyi) : check mistake in docs +- Open Source Projects + - [pyglet](https://github.com/pyglet/pyglet): GUI and graphics + - `tomlkit` / `rtoml` toml parser + - `xmltodict`: translate data between xml and dict + - `pyperclip`: paste board! + - `rapier2d`: Phy simulate engine + +- Main contributors + - [@Rayawa](https://github.com/Rayawa) : check mistake in docs & some translates + - [@rouxiao-you](https://github.com/ruoxiao-you) : translate chinese to English + - [@Billchyi](https://github.com/Billchyi) : check mistake in docs ## Other links diff --git a/libs/Difficult_Rocket_rs/src/Cargo.toml b/libs/Difficult_Rocket_rs/src/Cargo.toml index 4bfc5bc..cc3e355 100644 --- a/libs/Difficult_Rocket_rs/src/Cargo.toml +++ b/libs/Difficult_Rocket_rs/src/Cargo.toml @@ -11,6 +11,9 @@ license-file = '../../LICENSE' name = 'difficult_rocket_rs' crate-type = ["cdylib"] +[profile.dev.package.rapier2d-f64] +opt-level = 3 + [dependencies.rapier2d-f64] version = "0.17.1" features = ["simd-stable"] diff --git a/libs/Difficult_Rocket_rs/src/src/types.rs b/libs/Difficult_Rocket_rs/src/src/types.rs index ae9ecd6..6c746b7 100644 --- a/libs/Difficult_Rocket_rs/src/src/types.rs +++ b/libs/Difficult_Rocket_rs/src/src/types.rs @@ -66,14 +66,127 @@ pub mod sr1 { } } +#[allow(unused)] +pub mod math { + + #[derive(Clone, Copy)] + pub struct Point2D { + pub x: f64, + pub y: f64 + } + + impl Point2D { + pub fn new(x: f64, y: f64) -> Self { + Point2D{x, y} + } + + pub fn new_00() -> Self { Point2D { x: 0.0, y :0.0 } } + + #[inline] + pub fn distance(&self, other: &Point2D) -> f64 { + let dx = (other.x - self.x).powf(2.0); + let dy = (other.y - self.y).powf(2.0); + (dx + dy).powf(0.5) + } + + #[inline] + pub fn get_op(&self) -> f64 { + self.distance(&Point2D::new(0.0, 0.0)) + } + } + + #[derive(Clone, Copy)] + pub struct CircularArc { + pub r: f64, + // 半径 + pub pos: Point2D, + // 圆心位置 + pub start_angle: f64, + // 圆弧开始位置 角度值 + pub end_angle: f64, + // 圆弧结束位置 角度值 + } + + #[derive(Clone, Copy)] + pub struct OneTimeLine { + pub k: f64, + pub b: f64, + // y = kx + b + // kx + b - y = 0 + pub start: Point2D, + // start point + pub end: Point2D, + // end point + } + + #[derive(Clone, Copy)] + pub enum Edge { + OneTimeLine{data: OneTimeLine}, + CircularArc{data: CircularArc}, + } + + impl OneTimeLine { + #[inline] + pub fn pos_new(x1: f64, y1: f64, x2: f64, y2: f64) -> Self { + let k = (x2 - x1) / (y2 - y1); + let b = y1 - (x1 * k); + let start = Point2D::new(x1, y1); + let end = Point2D::new(x2, y2); + OneTimeLine { k, b, start, end } + } + + #[inline] + pub fn point_new(a: &Point2D, b: &Point2D) -> Self { + OneTimeLine::pos_new(a.x, a.y, b.x, b.y) + } + + pub fn point1_k_b_new(point: &Point2D, k: Option, b: Option) -> Self { + let mut k_: f64; + let mut b_: f64; + match (k, b) { + (Some(k), None) => { + k_ = k; + b_ = point.y - (k * point.x) + }, + (None, Some(b)) => { + b_ = b; + k_ = (point.y - b) / point.x; + }, + (Some(k), Some(b)) => { + k_ = k; + b_ = b; + }, + _ => { + k_ = point.y / point.x; + b_ = 0.0; + } + } + OneTimeLine{ + k: k_, + b: b_, + start: *point, + end: Point2D::new(0.0, b_) + } + } + + pub fn point_d() -> f64 { + 1.0 + } + } +} + #[allow(dead_code)] pub mod dr { + use super::math; + + #[derive(Clone, Copy)] pub enum ConnectType { Stick, FixedPoint, RotatePoint, } + #[derive(Clone, Copy)] pub struct Connect { pub c_type: ConnectType, pub d_pos: f64, @@ -81,6 +194,16 @@ pub mod dr { } + #[derive(Clone)] + pub struct Shape { + pub x: f64, + pub y: f64, + pub angle: f64, + // 旋转角度 角度值 + pub bounds: Vec + } + + #[derive(Clone, Copy)] pub enum PartType { Pod, Separator, @@ -119,4 +242,3 @@ pub mod dr { } } } -