Applies to: Nevron Chart for .NET
Triangulated Surface Chart is not displaying
Q: I am generating data to display a Triangulated Surface chart. However, this specific set of data produces empty chart area and the Triangulated Surface is not displayed. What may be causing this?
A: In some cases, geometric calculations that are based on floating point arithmetic return incorrect results (due to the limited precision of FP arithmetic). This spoils the logic of the triangulation algorithm and it fails to produce a result. This is most likely to happen when the input set of points forms a regular structure in the XZ plane - like for example a grid or a circle. Such input sets are considered degenerate for triangulation algorithms.
You will have to set the UsePreciseGeometry property to true. When the UsePreciseGeometry property, the triangulation uses more precise calculations. This makes the algorithm robust, but at a certain performance cost. If possible, you can also use mesh surface series instead of triangulated surface.
Following is an example for creating a Triangulated Surface chart with UsePreciseGeometry property set to true:
[C#]
using
System;
using
System.Windows.Forms;
using
Nevron.Chart;
using
Nevron.Chart.WinForm;
using
Nevron.GraphicsCore;
...
private
void
Form1_Load(
object
sender, EventArgs e)
{
nChartControl1.Controller.Tools.Add(
new
NSelectorTool());
nChartControl1.Controller.Tools.Add(
new
NTrackballTool());
NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
chart.Enable3D =
true
;
chart.Width = 55;
chart.Depth = 55;
chart.Height = 30;
chart.Projection.Type = ProjectionType.Perspective;
chart.Projection.Elevation = 30;
chart.Projection.Rotation = -60;
chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights);
NTriangulatedSurfaceSeries triangulatedSurface =
new
NTriangulatedSurfaceSeries();
chart.Series.Add(triangulatedSurface);
triangulatedSurface.UsePreciseGeometry =
true
;
triangulatedSurface.FrameMode = SurfaceFrameMode.Mesh;
for
(
int
j = 0; j < 30; j++)
{
for
(
int
i = 0; i < 30; i++)
{
double
yPoint = Math.Sin(i * 0.1) * Math.Cos(j * 0.1);
triangulatedSurface.XValues.Add(i);
triangulatedSurface.ZValues.Add(j);
triangulatedSurface.Values.Add(yPoint);
}
}
}
[VB.NET]
Imports
System
Imports
System.Windows.Forms
Imports
Nevron.Chart
Imports
Nevron.Chart.WinForm
Imports
Nevron.GraphicsCore
...
Private
Sub
Form1_Load(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
NChartControl1.Controller.Tools.Add(
New
NSelectorTool())
NChartControl1.Controller.Tools.Add(
New
NTrackballTool())
Dim
chart
As
NCartesianChart =
DirectCast
(NChartControl1.Charts(0), NCartesianChart)
chart.Enable3D =
True
chart.Width = 55
chart.Depth = 55
chart.Height = 30
chart.Projection.Type = ProjectionType.Perspective
chart.Projection.Elevation = 30
chart.Projection.Rotation = -60
chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights)
Dim
triangulatedSurface
As
New
NTriangulatedSurfaceSeries()
chart.Series.Add(triangulatedSurface)
triangulatedSurface.UsePreciseGeometry =
True
triangulatedSurface.FrameMode = SurfaceFrameMode.Mesh
For
j
As
Integer
= 0
To
29
For
i
As
Integer
= 0
To
29
Dim
yPoint
As
Double
= Math.Sin(i * 0.1) * Math.Cos(j * 0.1)
triangulatedSurface.XValues.Add(i)
triangulatedSurface.ZValues.Add(j)
triangulatedSurface.Values.Add(yPoint)
Next
Next
End
Sub
Article ID: 141, Created On: 11/25/2010, Modified: 12/1/2010