Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PI - 260] Add spline interpolation #64

Closed
wants to merge 12 commits into from

Conversation

Alffaza
Copy link
Member

@Alffaza Alffaza commented Feb 12, 2023

Jira Link: https://ichiro-its.atlassian.net/browse/PI-260

Description

Added spline and polynomial classes that can be used for calculations

Type of Change

  • Bugfix
  • Enhancement
  • New feature
  • Breaking change (fix or feature that would cause the existing functionality to not work as expected)

How Has This Been Tested?

  • New unit tests added.
  • Manual tested.

Checklist:

  • Using Branch Name Convention
    • feature/JIRA-ID-SHORT-DESCRIPTION if has a JIRA ticket
    • enhancement/SHORT-DESCRIPTION if has/has no JIRA ticket and contain enhancement
    • hotfix/SHORT-DESCRIPTION if the change doesn't need to be tested (urgent)
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have made the documentation for the corresponding changes.

include/keisan/spline/spline.hpp Outdated Show resolved Hide resolved
include/keisan/spline/spline.hpp Outdated Show resolved Hide resolved
src/spline/polynom.cpp Outdated Show resolved Hide resolved
include/keisan/spline/smooth_spline.hpp Outdated Show resolved Hide resolved
@borednuna borednuna force-pushed the feature/implement-spline-interpolation branch 2 times, most recently from 7c99d7d to e942fd2 Compare December 2, 2023 07:39
@@ -0,0 +1,54 @@
// Copyright (c) 2023 ICHIRO ITS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see this.

Comment on lines +34 to +50
struct PointTime
{
float point;
float time;
};

SmoothSpline();
explicit SmoothSpline(const std::vector<PointTime>& point_times);
~SmoothSpline();

void add_point(const Polynom& polynom);
void add_point(double value, double t);
Polynom polynomial_fit(
double pos1, double pos2, double vel1, double vel2, double acc1, double acc2, double t);

private:
std::vector<float> points;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest not mixing between float and double. Mixing them may add more type conversions, and the double precision in double will be useless if it's being operated with a float.

Comment on lines +36 to +39
std::vector<Polynom>& Spline::get_splines()
{
return splines;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're exposing the splines as a reference, why not simply remove the get_splines function and expose the splines as a public property instead?

Comment on lines +41 to +44
void Spline::add_spline(const Polynom& polynom)
{
splines.push_back(polynom);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If splines is exposed as a public property, we can simply call splines.push_back directly. There's no need to declare another add_spline function.

Comment on lines +37 to +40
double Polynom::get_value(double value)
{
return get_value(value, OrderType::POSITION);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, we can simply use the other function but declared it like this:

double Polynom::get_value(double value, int derivative_order = OrderType::POSITION);

Comment on lines +28 to +30
Polynom::Polynom()
{
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to have this constructor?

Comment on lines +28 to +30
SmoothSpline::SmoothSpline() {}

SmoothSpline::~SmoothSpline() {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to have these constructor and destructor?

Comment on lines +28 to +34
Spline::Spline()
{
}

Spline::~Spline()
{
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to have these constructor and destructor?

Comment on lines +76 to +77
std::vector<double> coefficients;
coefficients.resize(6);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI you can do this:

Suggested change
std::vector<double> coefficients;
coefficients.resize(6);
std::vector<double> coefficients(6);

Comment on lines +89 to +90
Polynom polynom(coefficients);
return polynom;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI you can do this:

Suggested change
Polynom polynom(coefficients);
return polynom;
return Polynom(coefficients);

@FaaizHaikal FaaizHaikal deleted the feature/implement-spline-interpolation branch December 24, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants