1
General / Re: Cosine Interpolation Rendering as linear
« on: September 01, 2022, 07:59:16 am »
Thanks Kojack, had just figured it out before I saw your post
Yeah my issue was that I was interpolating on both axis, rather than just the Y, and so the cosine waves were going in opposite directions, cancelling out and making a straight(linear) interpolation.
All sorted now, just had to change this
to this:
Also I'm not interpolating between 1000 points, those 1000 points are the points being drawn between the two points i am interpolating between, to make a solid line. Ik using a random number to pick numbers between 0 and 1 isnt most efficient but I am not going to be ending up rendering these lines in future, it was just so I could see my cosine interpolation function was working.
Yeah my issue was that I was interpolating on both axis, rather than just the Y, and so the cosine waves were going in opposite directions, cancelling out and making a straight(linear) interpolation.
All sorted now, just had to change this
return sf::Vector2f(a.x * (1-f) + b.x * f,
a.y * (1 - f) + b.y * f);
a.y * (1 - f) + b.y * f);
to this:
return sf::Vector2f(a.x * (1-randN ) + b.x * randN ,
a.y * (1 - f) + b.y * f);
but yeah thanks for help regardless.a.y * (1 - f) + b.y * f);
Also I'm not interpolating between 1000 points, those 1000 points are the points being drawn between the two points i am interpolating between, to make a solid line. Ik using a random number to pick numbers between 0 and 1 isnt most efficient but I am not going to be ending up rendering these lines in future, it was just so I could see my cosine interpolation function was working.