add typing, add readme thanks

good job copilot!
This commit is contained in:
shenjack 2023-03-28 23:59:13 +08:00
parent f059466e53
commit 391f3df7b8
3 changed files with 27 additions and 23 deletions

View File

@ -56,3 +56,9 @@ cd src
- [ ] main Calculate protocol
- [ ] other protocols
## Thanks
Great thanks to Github Copilot!
It helps me a lot in Vector and Matrix calculation and protocol implementation.
(there are A LOT of code generated by copilot)
(even this sentence is generated by copilot)

View File

@ -42,6 +42,10 @@ if TYPE_CHECKING:
def __truediv__(self, other: "Vector2_rs") -> "Vector2_rs": ...
def __floordiv__(self, other: "Vector2_rs") -> "Vector2_rs": ...
def __repr__(self) -> str: ...
@property
def x(self) -> float: ...
@property
def y(self) -> float: ...
class Vector3_rs:
@ -52,6 +56,12 @@ if TYPE_CHECKING:
def __truediv__(self, other: "Vector3_rs") -> "Vector3_rs": ...
def __floordiv__(self, other: "Vector3_rs") -> "Vector3_rs": ...
def __repr__(self) -> str: ...
@property
def x(self) -> float: ...
@property
def y(self) -> float: ...
@property
def z(self) -> float: ...
class Vector4_rs:
@ -62,6 +72,14 @@ if TYPE_CHECKING:
def __truediv__(self, other: "Vector4_rs") -> "Vector4_rs": ...
def __floordiv__(self, other: "Vector4_rs") -> "Vector4_rs": ...
def __repr__(self) -> str: ...
@property
def x(self) -> float: ...
@property
def y(self) -> float: ...
@property
def z(self) -> float: ...
@property
def w(self) -> float: ...
class Matrix3_rs: ...

View File

@ -6,25 +6,23 @@
* -------------------------------
*/
pub mod macros {}
pub mod vector {
use std::ops::{Add, Div, Mul, Sub};
#[derive(Debug, Clone, Copy, PartialOrd)]
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct Vector2 {
pub x: f64,
pub y: f64,
}
#[derive(Debug, Clone, Copy, PartialOrd)]
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct Vector3 {
pub x: f64,
pub y: f64,
pub z: f64,
}
#[derive(Debug, Clone, Copy, PartialOrd)]
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct Vector4 {
pub x: f64,
pub y: f64,
@ -73,12 +71,6 @@ pub mod vector {
}
}
impl PartialEq for Vector2 {
fn eq(&self, other: &Self) -> bool {
self.x == other.x && self.y == other.y
}
}
impl Add for Vector3 {
type Output = Self;
@ -111,12 +103,6 @@ pub mod vector {
}
}
impl PartialEq for Vector3 {
fn eq(&self, other: &Self) -> bool {
self.x == other.x && self.y == other.y && self.z == other.z
}
}
impl Add for Vector4 {
type Output = Self;
@ -169,12 +155,6 @@ pub mod vector {
}
}
impl PartialEq for Vector4 {
fn eq(&self, other: &Self) -> bool {
self.x == other.x && self.y == other.y && self.z == other.z && self.w == other.w
}
}
impl VectorTrait for Vector2 {
fn len(&self) -> i8 {
return 2;