Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
run: cargo build --verbose --all-features
- name: Run tests
run: cargo test --verbose
run: cargo test --verbose --all-features
56 changes: 38 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ https://www.cs.utexas.edu/~ear/cs341/automatabook/AutomataTheoryBook.pdf
https://dl.acm.org/doi/pdf/10.1145/360825.360855
https://docs.google.com/document/d/1KkKC2-ozJkvbWQIAXeJ1MUGqxjn19c-Mmc7RtxFTA3c/edit?tab=t.0
https://ntrs.nasa.gov/api/citations/19900013774/downloads/19900013774.pdf

https://www.cs.unc.edu/techreports/96-043.pdf
2 changes: 1 addition & 1 deletion update_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = "0.2.5"
VERSION = "0.3.0"

locations = [
"./vec-utils/Cargo.toml",
Expand Down
4 changes: 2 additions & 2 deletions vec-utils-py/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vec-utils-py"
version = "0.2.5"
version = "0.3.0"
edition = "2024"
authors = ["Akari Harada <[email protected]>"]
license = "GPL-3"
Expand All @@ -17,4 +17,4 @@ pyo3 = { version = "0.27.2", features = [
"generate-import-lib"
] }
rayon = "1.11.0"
vec-utils = { path = "../vec-utils" }
vec-utils = { path = "../vec-utils", features = ["matrix"] }
2 changes: 1 addition & 1 deletion vec-utils-py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "vec-utils-py"
version = "0.2.5"
version = "0.3.0"
requires-python = ">=3.9"
authors = [
{ name="Akari202", email="[email protected]" }
Expand Down
2 changes: 1 addition & 1 deletion vec-utils-py/src/quat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl Quat {
}

fn to_rotation_matrix(&self) -> [[f64; 3]; 3] {
self.inner.to_rotation_matrix()
self.inner.to_rotation_matrix().to_nested_arr()
}

fn rotate(&self, v: &Vec3d) -> Vec3d {
Expand Down
8 changes: 6 additions & 2 deletions vec-utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vec-utils"
version = "0.2.5"
version = "0.3.0"
edition = "2024"
authors = ["Akari Harada <[email protected]>"]
license = "GPL-3"
Expand All @@ -10,6 +10,9 @@ name = "vec_utils"

[dependencies]
libm = { version = "0.2.15" }
matrixmultiply = { version = "0.3.10", default-features = false, features = [
"cgemm"
], optional = true }
rkyv = { version = "0.8.12", default-features = false, features = ["bytecheck"], optional = true }
serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true }

Expand All @@ -19,6 +22,7 @@ pretty_assertions = "1.4.1"

[features]
default = ["std"]
matrix = ["dep:matrixmultiply"]
rkyv = ["dep:rkyv"]
serde = ["dep:serde"]
std = ["rkyv?/std", "serde?/std"]
std = ["matrixmultiply?/std", "rkyv?/std", "serde?/std"]
38 changes: 38 additions & 0 deletions vec-utils/src/complex.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use core::cmp::Ordering;
use core::fmt;
use core::ops::{Add, Div, Index, Mul, Sub};

Expand All @@ -7,6 +8,7 @@ use crate::{
};

/// A complex number
#[repr(C)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(
feature = "rkyv",
Expand Down Expand Up @@ -241,6 +243,42 @@ impl_single_op_variants_other!(
"Divide a real number by a complex number"
);

impl PartialOrd for Complex {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
let self_mag_sq = self.real * self.real + self.imaginary * self.imaginary;
let other_mag_sq = other.real * other.real + other.imaginary * other.imaginary;

self_mag_sq.partial_cmp(&other_mag_sq)
}
}

impl PartialEq<f64> for Complex {
fn eq(&self, other: &f64) -> bool {
self.imaginary == 0.0 && self.real == *other
}
}

impl PartialOrd<f64> for Complex {
fn partial_cmp(&self, other: &f64) -> Option<Ordering> {
let self_mag_sq = self.real * self.real + self.imaginary * self.imaginary;
let other_mag_sq = other * other;

self_mag_sq.partial_cmp(&other_mag_sq)
}
}

impl PartialEq<Complex> for f64 {
fn eq(&self, other: &Complex) -> bool {
other.eq(self)
}
}

impl PartialOrd<Complex> for f64 {
fn partial_cmp(&self, other: &Complex) -> Option<Ordering> {
other.partial_cmp(self).map(Ordering::reverse)
}
}

impl Index<usize> for Complex {
type Output = f64;

Expand Down
3 changes: 0 additions & 3 deletions vec-utils/src/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//! Geometry module
//! This module contains geometric shapes and operations on them.

/// Circles
pub mod circle;
/// Intersections
Expand Down
19 changes: 12 additions & 7 deletions vec-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#![no_std]
#![deny(missing_docs)]
#![warn(clippy::pedantic)]
#![deny(
missing_docs,
clippy::undocumented_unsafe_blocks,
clippy::unnecessary_safety_doc
)]
#![allow(
clippy::must_use_candidate,
clippy::many_single_char_names,
clippy::return_self_not_must_use
clippy::return_self_not_must_use,
clippy::derive_ord_xor_partial_ord,
incomplete_features
)]
#![cfg_attr(not(feature = "std"), feature(core_float_math))]
#![cfg_attr(feature = "matrix", feature(generic_const_exprs))]
#![doc(test(attr(deny(dead_code))))]
//! A crate for 3D vector, quaternion, geometry, and matrix operations
//! plus some miscellaneous other common things.
Expand All @@ -24,11 +31,9 @@ pub mod complex;
pub mod geometry;
/// Internal macros
pub(crate) mod macros;
/// Functions for working with matrices
/// currently only 2x2, 3x3, and 4x4 matrices are supported
/// with functions for calculating the determinant, minor, and cofactor
/// only available on std until i get around to fixing it or <https://github.com/rust-lang/rust/issues/137578> gets merged
#[cfg(feature = "std")]
/// Matrix operations and functions.
/// Requires the "matrix" feature
#[cfg(feature = "matrix")]
pub mod matrix;
/// Quaternion operations and functions
pub mod quat;
Expand Down
Loading
Loading