From 501580bd6950132b1db90901564c49caa1895789 Mon Sep 17 00:00:00 2001 From: ShisatoYano Date: Tue, 20 Aug 2024 15:50:24 +0000 Subject: [PATCH] import cubic spline 2d class --- .../cubic_spline_course/cubic_spline_2d.py | 3 ++ .../cubic_spline/cubic_spline_2d_plot.py | 39 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/components/course/cubic_spline_course/cubic_spline_2d.py b/src/components/course/cubic_spline_course/cubic_spline_2d.py index 3326eeb..d0cbac1 100644 --- a/src/components/course/cubic_spline_course/cubic_spline_2d.py +++ b/src/components/course/cubic_spline_course/cubic_spline_2d.py @@ -19,3 +19,6 @@ class CubicSpline2D: def __init__(self, x_points, y_points): print(x_points) print(y_points) + + def _calculate_distance_from_start(self, x_points, y_points): + pass diff --git a/src/simulations/course/cubic_spline/cubic_spline_2d_plot.py b/src/simulations/course/cubic_spline/cubic_spline_2d_plot.py index e69de29..f6218fd 100644 --- a/src/simulations/course/cubic_spline/cubic_spline_2d_plot.py +++ b/src/simulations/course/cubic_spline/cubic_spline_2d_plot.py @@ -0,0 +1,39 @@ +""" +cubic_spline_2d_plot.py + +Author: Shisato Yano +""" + +# import path setting +import numpy as np +import sys +import matplotlib.pyplot as plt +from pathlib import Path + +abs_dir_path = str(Path(__file__).absolute().parent) +relative_path = "/../../../components/" + +sys.path.append(abs_dir_path + relative_path + "course/cubic_spline_course") + +# import component module +from cubic_spline_2d import CubicSpline2D + + +# flag to show plot figure +# when executed as unit test, this flag is set as false +show_plot = True + + +def main(): + """ + Main process function + """ + + x_points = [-2.5, 0.0, 2.5, 5.0, 7.5, 3.0, -1.0] + y_points = [0.7, -6, 5, 6.5, 0.0, 5.0, -2.0] + + cs_2d = CubicSpline2D(x_points, y_points) + + +if __name__ == "__main__": + main()