To handle collision prevention, for example, I set the program to issue a warning when near to obstacles. The x and y coordinates of obstacles are put into array.
Now I would like to draw a smooth profile that is like blocks of rectangles. However, I get slanted lines whenever there is change in y-coordinate.
A small part of the code I used are as followed, assuming the coordinates of x and y arrays should give rectangular shaped profile with rises and falls as x changes, maybe like building a castle with some variation in height y.
for (int i = 0; i < Copy_length; i++)
{
chart1.Series["Series1"].Points.AddXY(X[i],Y[i]);
}
chart1.Series["Series1"].Color = Color.FromArgb(100, Color.Olive);
chart1.Series["Series1"].Points.DataBindXY(X, Y1, Y2);
Other suggestions for handling of collision prevention are welcome too.
You could add some data points to create the steps you seem to want:
void makeSteps(Series S)
{
List<DataPoint> points = S.Points.ToList();
S.Points.Clear();
for(int i = 0; i < points.Count - 1; i++)
{
S.Points.Add(points[i]);
S.Points.AddXY(points[i + 1].XValue, points[i].YValues[0]);
}
}
This should answer what the title asks. No idea how that relates to or could help with collision detection..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.