pub struct TwoPolynomials<T, P>where
P: Generic1DPoly<T>,
T: Clone + Neg<Output = T> + AddAssign + Add<Output = T> + Mul<Output = T> + MulAssign + From<SmallIntegers> + Sub<Output = T>,{ /* private fields */ }Expand description
T is the type being used to represent the real numbers have two polynomials which can be used as functions from T to T so used for an R -> R^2 curve
Implementations§
Source§impl<const N: usize, T> TwoPolynomials<T, SymmetricalBasisPolynomial<N, T>>
impl<const N: usize, T> TwoPolynomials<T, SymmetricalBasisPolynomial<N, T>>
Source§impl<T, P> TwoPolynomials<T, P>
impl<T, P> TwoPolynomials<T, P>
Sourcepub fn differentiate(self) -> Result<Self, DifferentiateError>
pub fn differentiate(self) -> Result<Self, DifferentiateError>
differentiate each component
§Errors
the subspace for the components does not have to be closed under d/dx operator
pub fn evaluate_at(&self, t: T) -> (T, T)
pub fn evaluate_at_many<const POINT_COUNT: usize>( &self, ts: [T; POINT_COUNT], ) -> [(T, T); POINT_COUNT]
pub fn evaluate_at_zero(&self) -> (T, T)
pub fn evaluate_at_one(&self) -> (T, T)
pub fn evaluate_at_neg_one(&self) -> (T, T)
Sourcepub fn linear_approx_poly(
self,
around_here: PointSpecifier<T>,
) -> Result<Self, Result<DifferentiateError, MonomialError>>
pub fn linear_approx_poly( self, around_here: PointSpecifier<T>, ) -> Result<Self, Result<DifferentiateError, MonomialError>>
first order approximation around the given point
§Errors
it might fail because the subspace for each component does not have to be closed under d/dx operator
another possibility is that the subspace does not include the linear function x
that should be very unusual, because we typically truncate
by degree and 1 is too low of a degree to fall to the chopping block
Sourcepub fn apply_matrix(self, two_d_matrix: [[T; 2]; 2]) -> Selfwhere
P: Clone,
pub fn apply_matrix(self, two_d_matrix: [[T; 2]; 2]) -> Selfwhere
P: Clone,
A B x C D y
pub fn reflect_y(self) -> Self
pub fn reflect_x(self) -> Self
pub fn swap_axes(self) -> Self
Source§impl<T, P> TwoPolynomials<T, P>where
T: Clone + Neg<Output = T> + AddAssign + Add<Output = T> + Mul<Output = T> + MulAssign + From<SmallIntegers> + Sub<Output = T> + SubAssign + DivAssign<T>,
P: Generic1DPoly<T> + Clone + FundamentalTheorem<T>,
impl<T, P> TwoPolynomials<T, P>where
T: Clone + Neg<Output = T> + AddAssign + Add<Output = T> + Mul<Output = T> + MulAssign + From<SmallIntegers> + Sub<Output = T> + SubAssign + DivAssign<T>,
P: Generic1DPoly<T> + Clone + FundamentalTheorem<T>,
Sourcepub fn normals_to_point(
self,
point: (T, T),
zero_pred: &impl Fn(&T) -> bool,
my_sqrt: &impl Fn(&T) -> Option<T>,
my_cube_root: &impl Fn(&T) -> (Option<T>, Option<T>),
) -> Result<Vec<(T, usize)>, NormalTangentError>
pub fn normals_to_point( self, point: (T, T), zero_pred: &impl Fn(&T) -> bool, my_sqrt: &impl Fn(&T) -> Option<T>, my_cube_root: &impl Fn(&T) -> (Option<T>, Option<T>), ) -> Result<Vec<(T, usize)>, NormalTangentError>
given a parameterized curve in the plane find the values of the parameter where the tangent at that point is perpendicular to the displacement vector pointing between the given point and the curve
§Errors
- one of the errors associated with
differentiate - a dot product was not in the subspace
- a polynomial was not exactly solvable
Sourcepub fn tangents_to_points(
self,
point: (T, T),
zero_pred: &impl Fn(&T) -> bool,
my_sqrt: &impl Fn(&T) -> Option<T>,
my_cube_root: &impl Fn(&T) -> (Option<T>, Option<T>),
) -> Result<Vec<(T, usize)>, NormalTangentError>
pub fn tangents_to_points( self, point: (T, T), zero_pred: &impl Fn(&T) -> bool, my_sqrt: &impl Fn(&T) -> Option<T>, my_cube_root: &impl Fn(&T) -> (Option<T>, Option<T>), ) -> Result<Vec<(T, usize)>, NormalTangentError>
given a parameterized curve in the plane find the values of the parameter where the tangent at that point is in the same direction as the displacement vector pointing between the given point and the curve
§Errors
- one of the errors associated with
differentiate - a cross product was not in the subspace
- a polynomial was not exactly solvable
Sourcepub fn collision_curve(
self,
other: Self,
zero_pred: &impl Fn(&T) -> bool,
my_sqrt: &impl Fn(&T) -> Option<T>,
my_cube_root: &impl Fn(&T) -> (Option<T>, Option<T>),
) -> Result<Vec<(T, usize)>, NormalTangentError>
pub fn collision_curve( self, other: Self, zero_pred: &impl Fn(&T) -> bool, my_sqrt: &impl Fn(&T) -> Option<T>, my_cube_root: &impl Fn(&T) -> (Option<T>, Option<T>), ) -> Result<Vec<(T, usize)>, NormalTangentError>
given two parameterized curves in the plane find the values of the parameter where the distance between the two curves becomes 0
§Errors
- a norm squared was not in the subspace
- a polynomial was not exactly solvable
Sourcepub fn signed_curvature_times_speed_cubed_and_speed_squared(
self,
zero_pred: &impl Fn(&T) -> bool,
) -> Result<(P, P), NormalTangentError>
pub fn signed_curvature_times_speed_cubed_and_speed_squared( self, zero_pred: &impl Fn(&T) -> bool, ) -> Result<(P, P), NormalTangentError>
for the curvature kappa, take the absolute value of the first output polynomial (in P)
then divide by the speed cubed
the speed squared is the second output
we can’t do it purely within this level of generality with P
because you can’t take the square root
nor can we divide
§Errors
- one of the errors associated with
differentiate - a dot product was not in the subspace
- a cross product was not in the subspace
Sourcepub fn speed_squared(
self,
zero_pred: &impl Fn(&T) -> bool,
) -> Result<P, NormalTangentError>
pub fn speed_squared( self, zero_pred: &impl Fn(&T) -> bool, ) -> Result<P, NormalTangentError>
speed squared
§Errors
- one of the errors associated with
differentiate - a dot product was not in the subspace
Trait Implementations§
Source§impl<T, P> Add<(T, T)> for TwoPolynomials<T, P>
impl<T, P> Add<(T, T)> for TwoPolynomials<T, P>
Source§impl<T, P> Add for TwoPolynomials<T, P>
impl<T, P> Add for TwoPolynomials<T, P>
Source§impl<T, P> AddAssign<(T, T)> for TwoPolynomials<T, P>
impl<T, P> AddAssign<(T, T)> for TwoPolynomials<T, P>
Source§fn add_assign(&mut self, rhs: (T, T))
fn add_assign(&mut self, rhs: (T, T))
+= operation. Read moreSource§impl<T, P> AddAssign for TwoPolynomials<T, P>
impl<T, P> AddAssign for TwoPolynomials<T, P>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<T, P> Clone for TwoPolynomials<T, P>
impl<T, P> Clone for TwoPolynomials<T, P>
Source§impl<T, P> Mul<T> for TwoPolynomials<T, P>
impl<T, P> Mul<T> for TwoPolynomials<T, P>
Source§impl<T, P> MulAssign<T> for TwoPolynomials<T, P>
impl<T, P> MulAssign<T> for TwoPolynomials<T, P>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
*= operation. Read moreSource§impl<T, P> Neg for TwoPolynomials<T, P>
impl<T, P> Neg for TwoPolynomials<T, P>
Source§impl<T, P> Sub<(T, T)> for TwoPolynomials<T, P>
impl<T, P> Sub<(T, T)> for TwoPolynomials<T, P>
Source§impl<T, P> Sub for TwoPolynomials<T, P>
impl<T, P> Sub for TwoPolynomials<T, P>
Source§impl<T, P> SubAssign<(T, T)> for TwoPolynomials<T, P>
impl<T, P> SubAssign<(T, T)> for TwoPolynomials<T, P>
Source§fn sub_assign(&mut self, rhs: (T, T))
fn sub_assign(&mut self, rhs: (T, T))
-= operation. Read moreSource§impl<T, P> SubAssign for TwoPolynomials<T, P>
impl<T, P> SubAssign for TwoPolynomials<T, P>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read more