Skip to content

Commit

Permalink
Fixed raise_degree and integrate
Browse files Browse the repository at this point in the history
  • Loading branch information
gammelalf committed Sep 11, 2022
1 parent c434d30 commit 8094a7e
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ impl SimpleCurve {
match self {
SimpleCurve::Linear(curve) => curve.raise_degree().into(),
SimpleCurve::Quadratic(curve) => curve.raise_degree().into(),
SimpleCurve::Cubic(curve) => {
let matrix = curve.raise_degree().0.resize_horizontally(0, 0.0);
SimpleCurve::Higher(BezierCurve(matrix))
}
SimpleCurve::Cubic(curve) => curve.raise_degree().0.resize_horizontally(5, 0.0).into(),
SimpleCurve::Higher(curve) => curve.raise_degree().into(),
}
}
Expand Down Expand Up @@ -197,16 +194,16 @@ impl From<OBezierCurve<f64, Const<2>, Dynamic>> for SimpleCurve {
/// If the dynamic curve is actualy of degree 3 or lower,
/// it will be converted into a curve of the apropriate static degree.
fn from(curve: OBezierCurve<f64, Const<2>, Dynamic>) -> Self {
match curve.degree() {
1 => {
match curve.0.ncols() {
2 => {
let matrix = curve.0.columns_generic(0, Const::<2>).clone_owned();
SimpleCurve::Linear(BezierCurve(matrix))
}
2 => {
3 => {
let matrix = curve.0.columns_generic(0, Const::<3>).clone_owned();
SimpleCurve::Quadratic(BezierCurve(matrix))
}
3 => {
4 => {
let matrix = curve.0.columns_generic(0, Const::<4>).clone_owned();
SimpleCurve::Cubic(BezierCurve(matrix))
}
Expand Down Expand Up @@ -274,7 +271,7 @@ impl SimplePolynomial {
SimplePolynomial::Constant(poly) => poly.integrate().into(),
SimplePolynomial::Linear(poly) => poly.integrate().into(),
SimplePolynomial::Quadratic(poly) => poly.integrate().into(),
SimplePolynomial::Cubic(poly) => poly.integrate().0.resize_horizontally(0, 0.0).into(),
SimplePolynomial::Cubic(poly) => poly.integrate().0.resize_horizontally(5, 0.0).into(),
SimplePolynomial::Higher(poly) => poly.integrate().into(),
}
}
Expand Down Expand Up @@ -310,16 +307,16 @@ impl From<OPolynomial<f64, Const<2>, Dynamic>> for SimplePolynomial {
/// If the dynamic polynomial is actualy of degree 3 or lower,
/// it will be converted into a polynomial of the apropriate static degree.
fn from(polynomial: OPolynomial<f64, Const<2>, Dynamic>) -> Self {
match polynomial.degree() {
1 => {
match polynomial.0.ncols() {
2 => {
let matrix = polynomial.0.fixed_columns::<2>(0).clone_owned();
SimplePolynomial::Linear(Polynomial(matrix))
}
2 => {
3 => {
let matrix = polynomial.0.fixed_columns::<3>(0).clone_owned();
SimplePolynomial::Quadratic(Polynomial(matrix))
}
3 => {
4 => {
let matrix = polynomial.0.fixed_columns::<4>(0).clone_owned();
SimplePolynomial::Cubic(Polynomial(matrix))
}
Expand Down

0 comments on commit 8094a7e

Please sign in to comment.