Code Monkey home page Code Monkey logo

spline's People

Contributors

ttk592 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spline's Issues

.Solve(-) not working, gives out empty vector

Hi, great work on the splines code. I just have a small issue i stumbled upon using it in my project. I'm trying to recreate this splines into my code. Thanks in advance! Here is the issue, the splines and my code:
image
image

 int WorldGen(float Cont, float Eros, float PV ) {
			int worldHeight = 0;
			//Peakes & Valleys
			std::vector<double> x1, y1;
			x1.push_back(0.05f);
			y1.push_back(0.f);

			x1.push_back(0.1f);
			y1.push_back(0.1f);

			x1.push_back(0.325f);
			y1.push_back(0.2f);

			x1.push_back(0.5f);
			y1.push_back(0.21f);

			x1.push_back(0.65f);
			y1.push_back(0.55f);

			x1.push_back(0.9f);
			y1.push_back(0.61f);

			x1.push_back(1.f);
			y1.push_back(0.65f);
			tk::spline PVSpl;
			PVSpl.set_points(x1, y1);

			//Erosion
			std::vector<double> x2, y2;
			x2.push_back(0);
			y2.push_back(1);

			x2.push_back(0.15f);
			y2.push_back(0.55f);

			x2.push_back(0.3f);
			y2.push_back(0.41f);

			x2.push_back(0.32f);
			y2.push_back(0.45f);

			x2.push_back(0.45f);
			y2.push_back(PVSpl.solve(PV)[0]);

			x2.push_back(0.6f);
			y2.push_back(0.11f);

			x2.push_back(0.7f);
			y2.push_back(0.11f);

			x2.push_back(0.72f);
			y2.push_back(0.28f);

			x2.push_back(0.78f);
			y2.push_back(0.28f);

			x2.push_back(0.79f);
			y2.push_back(0.11f);

			x2.push_back(0.85f);
			y2.push_back(0.05f);

			x2.push_back(1.f);
			y2.push_back(0.05f);
			tk::spline ErosSpl;
			ErosSpl.set_points(x2, y2);

			//Continetalness
			std::vector<double> x3, y3;
			x3.push_back(0);
			y3.push_back(1);

			x3.push_back(0.09f);
			y3.push_back(0.025f);
			
			x3.push_back(0.345f);
			y3.push_back(0.025f);
			
			x3.push_back(0.385f);
			y3.push_back(0.435f);

			x3.push_back(0.515f);
			y3.push_back(0.435f);

			x3.push_back(0.525f);
			y3.push_back(0.9f);

			x3.push_back(0.55f);
			y3.push_back(0.915f);

			x3.push_back(0.72f);
			y3.push_back(ErosSpl.solve(Eros)[0]);

			x3.push_back(1.f);
			y3.push_back(0.98f);

			tk::spline ContSpl;
			ContSpl.set_points(x3, y3);
			
			worldHeight = ContSpl.solve(Cont)[0] * 100;

			return worldHeight;
		}

Compile error

When running make in the examples folder I get:

g++ -I../../alglib/src -I../src -O2 -DNDEBUG -Wall -c interpol_alglib.cpp -o interpol_alglib.o
interpol_alglib.cpp:4:37: fatal error: interpolation.h: No such file or directory
 #include "interpolation.h" // alglib

Looks like there is a missing file from alglib - perhaps document this better?

x need to increase monotonically

I use this to smooth the path, but the x of the path point is not necessarily monotonically increasing. How should I deal with it?

typo

Hi,

very nice code. Looks like you have a typo for case 2 below. Shouldn't it be 2.0*m_b0 instead of 2.0*m_b0*h?

if(x<m_x[0]) {
        // extrapolation to the left
        switch(order) {
        case 1:
            interpol=2.0*m_b0*h + m_c0;
            break;
        case 2:
            interpol=2.0*m_b0*h;
            break;
        default:
            interpol=0.0;
            break;
        }

first derivative

Is anyone adding functionality to calculate the first derivative at the interior points?

Is it a Cubic B-Spline Function?

I ran the code twice with 5 control points, in the second run I changed the fourth control point by a certain magnitude and observed that the global shape of the spline changed completely. I was hoping for more local control.

Computation time

Hello. Thank you for this library. It is quite easy to use.
Your benchmarks shows that it takes 0.2sec to access spline 10^7 times.
But it takes 100 seconds in my case. I build a spline and include it as a member to my class.
Then in another method I access this spline about 10^7 times.
Please suggest an algorithm optimization.
spl

More liberal license?

May I suggest a change to a more liberal license (MIT, LGPL, Apache2...)? I see it more appropriate for the scope and the amount of code. Of course it's your choice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.