diff options
author | eug-vs <eugene@eug-vs.xyz> | 2024-12-15 13:17:43 +0100 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2024-12-15 13:17:43 +0100 |
commit | 70afc5a7d871919776a64782e8b93404e6b0defd (patch) | |
tree | c3d8a273bddf4cbc3c55d06c751766b93b961a1f /src/constraint/slider.rs | |
parent | 297efa5127e83bea57132c503680dd348a725db5 (diff) | |
download | particle-physics-70afc5a7d871919776a64782e8b93404e6b0defd.tar.gz |
feat!: add raylib rendering
Diffstat (limited to 'src/constraint/slider.rs')
-rw-r--r-- | src/constraint/slider.rs | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/constraint/slider.rs b/src/constraint/slider.rs deleted file mode 100644 index 9f7973b..0000000 --- a/src/constraint/slider.rs +++ /dev/null @@ -1,50 +0,0 @@ -use std::usize; - -use nalgebra::{DVector, RowDVector}; - -use crate::{ - algebra::subspace::Line, - particle_system::{Scalar, N}, - ParticleSystem, Point, Vector, -}; - -use super::Constraint; - -pub struct SliderConstraint { - pub particle_id: usize, - - pub line: Line, - - jacobian: RowDVector<Scalar>, -} - -impl ParticleSystem { - pub fn add_slider_constraint(&mut self, particle_id: usize, direction: Vector) { - let point = self.particles[particle_id].position; - self.constraints.push(Box::new(SliderConstraint { - particle_id, - line: Line::new(point, [direction]), - jacobian: RowDVector::zeros(self.particles.len() * N), - })); - } -} - -impl Constraint for SliderConstraint { - fn get_particles(&self) -> Vec<usize> { - vec![self.particle_id] - } - - fn c(&self, q: &DVector<Scalar>) -> Scalar { - let position = q.fixed_rows::<N>(self.particle_id * N); - let point = Point::from_coordinates(position.into()); - self.line.distance(point) - } - - fn set_jacobian(&mut self, jacobian: RowDVector<Scalar>) { - self.jacobian = jacobian - } - - fn jacobian_prev(&self) -> RowDVector<Scalar> { - self.jacobian.clone() - } -} |