Easiest and fastest draw a sigmoid curve with Teechart - c++

i'm looking for a fast way to draw a sigmoid curve in Tchart. I really have difficulties to make it work. I tried to do it with Line Series and Fast Line Series but instead of a smoothed curve i obtain a straight one and i don't see an option to smoothen the curve. Is there an option that i can use to smoothen the curve or is there another C/C++ library which allows me to create bar charts and also sigmoid curves very easily and fast?

You can set the TLineSeries Smoothed property to true.
You can find an example in the "Features Demo", sources here:

Related

B-Spline for any number of control points

I am currently working on a soft body system using numeric spring physics and I have finally got that working. My issue is that everything is currently in straight lines.
I am aiming to replicate something similar to the game "The floor is Jelly" and everything work except the smooth corners and deformation which currently are straight and angular.
I have tried using Cubic Bezier equations but that just means every 3 nodes I have a new curve. Is there an equation for Bezier splines that take in n number of control points that will work with loop of vec2's (so node[0] is the first and last control point).
Sorry I don't any code to show for this but i'm completely stumped and googling is bringing up nothing.
Simply google "B-spline library" will give you many references. Having said this, B-spline is not your only choice. You can use cubic Hermite spline (which is defined by a series of points and derivatives) (see link for details) as well.
On the other hand, you can also continue using straight lines in your system and create a curve interpolating the straight line vertices just for display purpose. To create an interpolating curve thru a series of data points, Catmull-Rom spline is a good choice for easy implementation. This approach is likely to have a better performance than really using a B-spline curve in your system.
I would use B-splines for this problem since they can represent smooth curves with minimal number of control points. In addition finding the approximate smooth surface for a given data set is a simple linear algebra problem.
I have written a simple B-spline C++ library (includes Bezier curves as well) that I am using for scientific computations, here:
https://github.com/feevos/bsplines
it can accept arbitrary number of control points / multiplicities and give you back a basis. However, creating the B-spline curve that fits your data is something you have to do.
A great implementation of B-splines (but no Bezier curves) exists also in GNU GSL (
https://www.gnu.org/software/gsl/manual/html_node/Basis-Splines.html). Again here you have to implement the control points to be 2/3D for the given basis, and fix the boundary conditions to fit your data.
More information on open/closed curves and B-splines here:
https://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/index.html

smoothing rough edges contour opencv

I have this image
when you zoom it you can see the rough edges like this
I want to smoothen the rough edges such that they form an almost perfect curve/line,some what like this
I tried this method
Image edge smoothing
But I can't seem to save it as a bmp file. I tried Gaussian blur too but didn't get any much affect. The outlines are contours extracted from a binary image. Increasing the thickness of the contours removes the rough edges to a point but it changes the clear definition of the boundaries.
EDIT:-How about filled binary images?
This
to
Dilating would change the boundary too much.
What you are looking for is not possible in the manner you are thinking of. As #Miki stated, Digital images have an upper limit of resolution that you can not go further than it.
The solution is to represent your curves as vectorized curves. Then you can render at any resolution you want. One possible solution is to use Bezier Curves to represent the contours (or Spline). Then you may simply draw them with any resize fraction you want.
Here you can find some resources:
Are there any good libraries for solving cubic splines in C++?
Spline, B-Spline and NURBS C++ library
OpenCV - Fit a curve to a set of points

Tracing a bezier curve from an image for a cocos2d game

I was wondering if there is a tool that will allow me to construct/trace a closed bezier curve based on a background image?
Basically I have a background image that represents some 2d curve which could be of some weird shape like a race track and I want to place some items along this path.
I figured that if I can derive a quadratic bezier curve that will overlap the image I would be able to use the mathematical equations for this curve to compute individual points along its path..
Does anyone know if such tool exists? Is my approach reasonable or totally off and there is a much simpler solution?
Thank you in advance.
I suggest building it yourself. It shouldn't be too difficult to build a level creator where you add your own background image, place your bezier key points along where they need to be and export the points into a plist. It'll even give you room for extending it and customizing it for your game.
Also, if you're planning on tracing a path along a road for a racing game, consider constructing the background from smaller road/tree/grass sprites. This way you can give them specific properties (such as canDriveOn, canHit and so on) and based on customized behaviour defined for each one of them, your 'driveable' path would be derived implicitly.

2D interpolation

I've developed a little program that let me load an image then make some angle measurements onto it. Here is a screenshot (there is no image loaded in this screenshot).
When all the measurements are done I have a list of x, y and angle values. What I'd like to do is interpolate them to generate some kind of graph.
I would prefer to directly implement this functionality and not rely on any other library (as long as it's possible and not to complicated).
So basically I see two steps, first interpolating the data, second, generating a graph from it.
At first I was going to implement some bicubic interpolation but this kind of interpolation needs a regular grid, which I can't ensure.
For the moment I think I have to main options:
Convert my data to a regular grid and then do a bicubic interpolation.
Find an other kind of interpolation that doesn't require a regular grid.
What way do you think I should go and do you have any idea of which grid-redefining/interpolation I should use? I don't have any opinion on both methods but I think this is going to take me a lot of time and I wouldn't like to realize in the end that I am in a dead-end.
If this is of any relevance I'm working with Qt and on windows.
Edit: Basically I want something like that in the end:
What you are looking for is a 2D Least squares fitting function, and generating a heat map or a 3D surface.
QWT is nice library that can help with graphing it, but it is doable without it.
Google Least Squares 2D Calculation

Create smooth line to join N points in 3 dimensions

I have N points in 3-dimensional space. I need to join them using a line. However, if I do that using a simple line, it is not smooth and looks ugly.
My current approach is to use a Bezier curve, using the DeCasteljau algorithm for 4 points, and running that for each group of 4 points in my data set. However, the problem with this is that since I run it on say points 1-4, 5-8, 9-12, etc., separately, the line is not smooth between 4-5, 8-9, etc.
I also looked for other approaches; specifically I found this article about Catmull-Rom splines, which seem even better suited for my purpose, because the curve passes through all control points, unlike the Bezier curve. So I almost started implementing that, but then, I saw on that site that the formula works "assuming uniform spacing of control points". That is not the case for my problem.
So, my question is, what approach should I use -- Bezier, Catmull-Rom, or something completely different? If Bezier, then how to fix the non-smoothness between 4-5, 8-9, etc.? If Catmull-Rom, why won't the formula work if points are not evenly spaced, and what do I need instead?
EDIT: I am now pretty sure I want the Catmull-Rom spline, as it passes every control point which is an advantage for my application. Therefore, the main question I would like answered is why won't the formula on the link I provided work for non-uniformly spaced control points?
Thanks.
A couple of solutions:
Use a B-spline. This is a generalization of Bezier curves (a Bezier curve is a B-spline with no internal knot points.)
Use a cubic spline. Cubic splines are particularly easy to calculate. A cubic spline is continuous in the zero, first, and second derivatives across the control points. The third derivative, the cubic term, suffers a discontinuity at the control points, but it is very hard to see those discontinuities.
One key difference between a B-spline and a cubic spline is that the cubic spline will pass through all of the control points, while a B-spline does not. One way to think about it: Those internal control points are just suggestions for a B-spline but are mandatory for a cubic spline.
A meaningful line (although not the simplest to evaluate) can be found via Gaussian Processes. You set (or infer) the lengthscale over which you wish the line to vary (i.e. the smoothness of the line) and then the GP line is the most probable line through the data given the lengthscale. You can add noise to the model if you don't mind the line not passing through the data points.
Its a nice interpolation method because you can also obtain the standard deviation of your line. The line becomes more uncertain when you don't have much data in the vacinity.
You can read about them in chapter 45 of David MacKay's Information Theory, Inference, and Learning Algorithms - which you can download from the author's website here.
one solution is the following page in wikipedia: http://en.wikipedia.org/wiki/Bézier_curve, check the generalized approach for N control points.