mirror of
https://github.com/lisk77/comet.git
synced 2025-12-12 09:08:49 +00:00
chore(math): remove warnings
This commit is contained in:
parent
81bc1cb790
commit
a2715eafab
8 changed files with 30 additions and 33 deletions
|
|
@ -7,4 +7,5 @@ edition = "2021"
|
|||
comet_log = { path = "../comet_log" }
|
||||
rand = "0.9.0-beta.1"
|
||||
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"] }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{InnerSpace, Point};
|
||||
use crate::InnerSpace;
|
||||
|
||||
/// Representation of a Bezier curve of degree n in any (2-4) dimensions.
|
||||
pub struct Bezier<V: InnerSpace> {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::vector::{v2, v3, v4};
|
||||
use std::ops::*;
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait LinearTransformation {
|
||||
fn det(&self) -> f32;
|
||||
}
|
||||
|
|
@ -12,6 +13,7 @@ trait LinearTransformation {
|
|||
/// Representation of a 2x2 matrix.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct m2 {
|
||||
x00: f32,
|
||||
x01: f32,
|
||||
|
|
@ -208,6 +210,7 @@ impl Into<[[f32; 2]; 2]> for m2 {
|
|||
/// Representation of a 3x3 matrix.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct m3 {
|
||||
x00: f32,
|
||||
x01: f32,
|
||||
|
|
@ -497,6 +500,7 @@ impl Into<[[f32; 3]; 3]> for m3 {
|
|||
/// Representation of a 4x4 matrix.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct m4 {
|
||||
x00: f32,
|
||||
x01: f32,
|
||||
|
|
|
|||
|
|
@ -323,9 +323,12 @@ impl ValueNoise {
|
|||
let mut f = 0.0;
|
||||
let mut amplitude = 0.5;
|
||||
|
||||
f += amplitude * self.noise(uv);
|
||||
uv = (uv.0 * 2.0, uv.1 * 2.0);
|
||||
amplitude *= 0.5;
|
||||
for _ in 0..4 {
|
||||
f += amplitude * self.noise(uv);
|
||||
uv = (uv.0 * 2.0, uv.1 * 2.0);
|
||||
amplitude *= 0.5;
|
||||
}
|
||||
|
||||
f = ((f / max_amplitude) + 1.0) * 0.5;
|
||||
|
||||
noise.push(f);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ pub trait Point {
|
|||
}
|
||||
|
||||
/// Representation of a 2D point.
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct p2 {
|
||||
x: f32,
|
||||
|
|
@ -36,6 +37,7 @@ impl p2 {
|
|||
}
|
||||
|
||||
/// Representation of a 3D point.
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct p3 {
|
||||
x: f32,
|
||||
|
|
@ -81,7 +83,7 @@ impl Point for p2 {
|
|||
Self { x, y }
|
||||
}
|
||||
|
||||
fn to_vec(&self) -> v2 {
|
||||
fn to_vec(&self) -> impl InnerSpace {
|
||||
v2::new(self.x, self.y)
|
||||
}
|
||||
}
|
||||
|
|
@ -93,23 +95,11 @@ impl Point for p3 {
|
|||
Self { x, y, z }
|
||||
}
|
||||
|
||||
fn to_vec(&self) -> v3 {
|
||||
fn to_vec(&self) -> impl InnerSpace {
|
||||
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 {
|
||||
fn from(v: v2) -> Self {
|
||||
Self::from_vec(v)
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ impl Div for Polynomial {
|
|||
let divisor = other.coefficients.clone();
|
||||
while dividend.len() >= divisor.len() {
|
||||
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();
|
||||
for (j, &d) in divisor.iter().enumerate() {
|
||||
dividend[i + j] -= quotient[i] * d;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ pub struct Quat {
|
|||
|
||||
impl Quat {
|
||||
/// The zero quaternion.
|
||||
#[allow(unused)]
|
||||
const ZERO: Self = Self {
|
||||
s: 0.0,
|
||||
v: v3 {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
use crate::point::{p2, p3};
|
||||
use crate::quaternion::Quat;
|
||||
use crate::Point;
|
||||
use crate::{
|
||||
point::{p2, p3},
|
||||
quaternion::Quat,
|
||||
Point,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::ops::*;
|
||||
|
||||
pub trait InnerSpace:
|
||||
|
|
@ -31,8 +34,7 @@ pub trait InnerSpace:
|
|||
|
||||
/// Representation of a 2D vector
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct v2 {
|
||||
x: f32,
|
||||
|
|
@ -175,8 +177,7 @@ impl Into<v2> for [f32; 2] {
|
|||
|
||||
/// Representation of a 2D integer vector
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct v2i {
|
||||
x: i64,
|
||||
|
|
@ -423,8 +424,7 @@ impl Into<[f32; 2]> for v2i {
|
|||
|
||||
/// Representation of a 3D vector
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct v3 {
|
||||
pub x: f32,
|
||||
|
|
@ -620,8 +620,7 @@ impl Into<v3> for [f32; 3] {
|
|||
|
||||
/// Representation of a 3D integer vector
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct v3i {
|
||||
pub x: i64,
|
||||
|
|
@ -824,8 +823,7 @@ impl From<v3> for v3i {
|
|||
|
||||
/// Representation of a 4D vector
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct v4 {
|
||||
x: f32,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue