chore(math): remove warnings

This commit is contained in:
lisk77 2025-11-02 14:50:00 +01:00
parent 81bc1cb790
commit a2715eafab
8 changed files with 30 additions and 33 deletions

View file

@ -8,3 +8,4 @@ comet_log = { path = "../comet_log" }
rand = "0.9.0-beta.1" rand = "0.9.0-beta.1"
image = { version = "0.24", default_features = false, features = ["png", "jpeg", "hdr"] } image = { version = "0.24", default_features = false, features = ["png", "jpeg", "hdr"] }
chrono = "0.4.40" chrono = "0.4.40"
serde = { version = "1.0", features = ["derive"] }

View file

@ -1,4 +1,4 @@
use crate::{InnerSpace, Point}; use crate::InnerSpace;
/// Representation of a Bezier curve of degree n in any (2-4) dimensions. /// Representation of a Bezier curve of degree n in any (2-4) dimensions.
pub struct Bezier<V: InnerSpace> { pub struct Bezier<V: InnerSpace> {

View file

@ -1,6 +1,7 @@
use crate::vector::{v2, v3, v4}; use crate::vector::{v2, v3, v4};
use std::ops::*; use std::ops::*;
#[allow(dead_code)]
trait LinearTransformation { trait LinearTransformation {
fn det(&self) -> f32; fn det(&self) -> f32;
} }
@ -12,6 +13,7 @@ trait LinearTransformation {
/// Representation of a 2x2 matrix. /// Representation of a 2x2 matrix.
#[repr(C)] #[repr(C)]
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
#[allow(non_camel_case_types)]
pub struct m2 { pub struct m2 {
x00: f32, x00: f32,
x01: f32, x01: f32,
@ -208,6 +210,7 @@ impl Into<[[f32; 2]; 2]> for m2 {
/// Representation of a 3x3 matrix. /// Representation of a 3x3 matrix.
#[repr(C)] #[repr(C)]
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
#[allow(non_camel_case_types)]
pub struct m3 { pub struct m3 {
x00: f32, x00: f32,
x01: f32, x01: f32,
@ -497,6 +500,7 @@ impl Into<[[f32; 3]; 3]> for m3 {
/// Representation of a 4x4 matrix. /// Representation of a 4x4 matrix.
#[repr(C)] #[repr(C)]
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
#[allow(non_camel_case_types)]
pub struct m4 { pub struct m4 {
x00: f32, x00: f32,
x01: f32, x01: f32,

View file

@ -323,9 +323,12 @@ impl ValueNoise {
let mut f = 0.0; let mut f = 0.0;
let mut amplitude = 0.5; let mut amplitude = 0.5;
for _ in 0..4 {
f += amplitude * self.noise(uv); f += amplitude * self.noise(uv);
uv = (uv.0 * 2.0, uv.1 * 2.0); uv = (uv.0 * 2.0, uv.1 * 2.0);
amplitude *= 0.5; amplitude *= 0.5;
}
f = ((f / max_amplitude) + 1.0) * 0.5; f = ((f / max_amplitude) + 1.0) * 0.5;
noise.push(f); noise.push(f);

View file

@ -7,6 +7,7 @@ pub trait Point {
} }
/// Representation of a 2D point. /// Representation of a 2D point.
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub struct p2 { pub struct p2 {
x: f32, x: f32,
@ -36,6 +37,7 @@ impl p2 {
} }
/// Representation of a 3D point. /// Representation of a 3D point.
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub struct p3 { pub struct p3 {
x: f32, x: f32,
@ -81,7 +83,7 @@ impl Point for p2 {
Self { x, y } Self { x, y }
} }
fn to_vec(&self) -> v2 { fn to_vec(&self) -> impl InnerSpace {
v2::new(self.x, self.y) v2::new(self.x, self.y)
} }
} }
@ -93,23 +95,11 @@ impl Point for p3 {
Self { x, y, z } Self { x, y, z }
} }
fn to_vec(&self) -> v3 { fn to_vec(&self) -> impl InnerSpace {
v3::new(self.x, self.y, self.z) v3::new(self.x, self.y, self.z)
} }
} }
impl Into<v2> for p2 {
fn into(self) -> v2 {
self.to_vec()
}
}
impl Into<v3> for p3 {
fn into(self) -> v3 {
self.to_vec()
}
}
impl From<v2> for p2 { impl From<v2> for p2 {
fn from(v: v2) -> Self { fn from(v: v2) -> Self {
Self::from_vec(v) Self::from_vec(v)

View file

@ -118,7 +118,7 @@ impl Div for Polynomial {
let divisor = other.coefficients.clone(); let divisor = other.coefficients.clone();
while dividend.len() >= divisor.len() { while dividend.len() >= divisor.len() {
let mut quotient = vec![0.0; dividend.len() - divisor.len() + 1]; let mut quotient = vec![0.0; dividend.len() - divisor.len() + 1];
let mut i = dividend.len() - divisor.len(); let i = dividend.len() - divisor.len();
quotient[i] = dividend.last().unwrap() / divisor.last().unwrap(); quotient[i] = dividend.last().unwrap() / divisor.last().unwrap();
for (j, &d) in divisor.iter().enumerate() { for (j, &d) in divisor.iter().enumerate() {
dividend[i + j] -= quotient[i] * d; dividend[i + j] -= quotient[i] * d;

View file

@ -11,6 +11,7 @@ pub struct Quat {
impl Quat { impl Quat {
/// The zero quaternion. /// The zero quaternion.
#[allow(unused)]
const ZERO: Self = Self { const ZERO: Self = Self {
s: 0.0, s: 0.0,
v: v3 { v: v3 {

View file

@ -1,6 +1,9 @@
use crate::point::{p2, p3}; use crate::{
use crate::quaternion::Quat; point::{p2, p3},
use crate::Point; quaternion::Quat,
Point,
};
use serde::{Deserialize, Serialize};
use std::ops::*; use std::ops::*;
pub trait InnerSpace: pub trait InnerSpace:
@ -31,8 +34,7 @@ pub trait InnerSpace:
/// Representation of a 2D vector /// Representation of a 2D vector
#[repr(C)] #[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Default)] #[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
pub struct v2 { pub struct v2 {
x: f32, x: f32,
@ -175,8 +177,7 @@ impl Into<v2> for [f32; 2] {
/// Representation of a 2D integer vector /// Representation of a 2D integer vector
#[repr(C)] #[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Default)] #[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
pub struct v2i { pub struct v2i {
x: i64, x: i64,
@ -423,8 +424,7 @@ impl Into<[f32; 2]> for v2i {
/// Representation of a 3D vector /// Representation of a 3D vector
#[repr(C)] #[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Default)] #[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
pub struct v3 { pub struct v3 {
pub x: f32, pub x: f32,
@ -620,8 +620,7 @@ impl Into<v3> for [f32; 3] {
/// Representation of a 3D integer vector /// Representation of a 3D integer vector
#[repr(C)] #[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Default)] #[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
pub struct v3i { pub struct v3i {
pub x: i64, pub x: i64,
@ -824,8 +823,7 @@ impl From<v3> for v3i {
/// Representation of a 4D vector /// Representation of a 4D vector
#[repr(C)] #[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Default)] #[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
pub struct v4 { pub struct v4 {
x: f32, x: f32,