This is how I create data points for the equation:

struct Sine_point {
double x;
double y;
};
Sine_point graph[2000];
for(int i = 0; i < 2000; i++) {
float x = (i - 1000.0) / 100.0;
graph[i].x = x;
graph[i].y = sin(x * 10.0) / (1.0 + x * x);
cout<<graph[i].x<<graph[i].y<<endl;
}
Now I want to build a graph based on these points. What I have tried so far is a program for building a straight line:
#include <vector>
#include "opencv2/highgui/highgui.hpp"
#include <opencv\cv.h>
#include <iostream>
#include<conio.h>
using namespace cv;
using namespace std;
int main()
{
std::vector<char> dataPtr(40000, 200);
cv::Point p1(0,0);
cv::Point p2(200, 200);
cv::Size size(200,200);
cv::Mat image(size, CV_8U, &(dataPtr[0]));
if (image.empty())
{
cout << "Error : Image cannot be created..!!" << endl;
system("pause");
return -1;
}
cv::line(image, p1, p2, 'r', 5, 8, 0);
namedWindow("MyWindow", CV_WINDOW_AUTOSIZE);
imshow("MyWindow", image);
waitKey(0);
destroyWindow("MyWindow");
return 0;
}
In this case, the cv: line is used, which binds the endpoints that I provided. But how can I continue to work with the data of my functions?
Update
Here's how I do it now:
int main()
{
std::vector<char> dataPtr(40000, 200);
cv::Size s(200,200);
cv::Mat image(s, CV_8U, &(dataPtr[0]));
if (image.empty())
{
cout << "Error : Image cannot be created..!!" << endl;
system("pause");
return -1;
}
struct Sine_point {
double x;
double y;
};
Sine_point graph[2000];
for(int i = 0; i < 2000; i++) {
float x = (i - 1000.0) / 100.0;
graph[i].x = x;
graph[i].y = sin(x * 10.0) / (1.0 + x * x);
cv::Point p1(graph[i].x,graph[i].y);
cv::Point p2(graph[i+1].x, graph[i+1].y);
cv::line(image, p1, p2, Scalar(0,0,255), 5, 8, 0);
}
namedWindow("MyWindow", CV_WINDOW_AUTOSIZE);
imshow("MyWindow", image);
waitKey(0);
destroyWindow("MyWindow");
return 0;
}
But now I get an empty image.