Eyeshot 11 Documentation
WinForms Control / Tutorials / Curvature mapping for curve and surfaces
In This Topic
    Curvature mapping for curve and surfaces
    In This Topic

    With the code samples reported in this article, you can display curvature mapping of surfaces and curves with Eyeshot.

     

    The following picture shows the curvature mapping of a surface:

    Please note that there are different types of surface's curvature to display: Kappa1, Kappa2, Mean and Gauss. You can learn more about surface curvatures at this link:

    http://en.wikipedia.org/wiki/Curvature

     

    The code used to display it, is reported below:

    protected override void OnLoad(EventArgs e) 
    { 
        // Loft 
        List<Point3D> array = new List<Point3D>(); 
    
        array.Add(new Point3D(0, 60, 0)); 
        array.Add(new Point3D(0, 40, -5)); 
        array.Add(new Point3D(0, 20, +15)); 
        array.Add(new Point3D(0, 0, 0)); 
    
        Curve first = Curve.GlobalInterpolation(array, 3); 
    
        array.Clear(); 
        array.Add(new Point3D(40, 60, 0)); 
        array.Add(new Point3D(40, 0, 10)); 
    
        Curve second = Curve.GlobalInterpolation(array, 1); 
    
        array.Clear(); 
        array.Add(new Point3D(80, 60, 0)); 
        array.Add(new Point3D(80, 30, 20)); 
        array.Add(new Point3D(80, 0, 5)); 
    
        Curve third = Curve.GlobalInterpolation(array, 2); 
    
        array.Clear(); 
        array.Add(new Point3D(120, 60, 0)); 
        array.Add(new Point3D(120, 0, 0)); 
    
        Curve fourth = Curve.GlobalInterpolation(array, 1); 
    
        array.Clear(); 
        array.Add(new Point3D(160, 60, 0)); 
        array.Add(new Point3D(160, 30, 10)); 
        array.Add(new Point3D(160, 0, 0)); 
    
        Curve fifth = Curve.GlobalInterpolation(array, 2); 
    
        Surface loft = Surface.Loft(new Curve[] { first, second, third, fourth, fifth }, 3); 
    
        viewportLayout1.Entities.Add(loft, Color.Aquamarine); 
    
                 
        viewportLayout1.Legends[0].ColorTable = Legend.RedToBlue9; 
    
        loft.ComputeCurvatureMap(viewportLayout1.Legends[0], curvatureType.Kappa1); 
    
        loft.ShowCurvature = true; 
    
        viewportLayout1.Legends[0].Visible = true; 
    }
    Protected Overrides Sub OnLoad(e As EventArgs)
        ' Loft 
        Dim array As New List(Of Point3D)()
    
        array.Add(New Point3D(0, 60, 0))
        array.Add(New Point3D(0, 40, -5))
        array.Add(New Point3D(0, 20, +15))
        array.Add(New Point3D(0, 0, 0))
    
        Dim first As Curve = Curve.GlobalInterpolation(array, 3)
    
        array.Clear()
        array.Add(New Point3D(40, 60, 0))
        array.Add(New Point3D(40, 0, 10))
    
        Dim second As Curve = Curve.GlobalInterpolation(array, 1)
    
        array.Clear()
        array.Add(New Point3D(80, 60, 0))
        array.Add(New Point3D(80, 30, 20))
        array.Add(New Point3D(80, 0, 5))
    
        Dim third As Curve = Curve.GlobalInterpolation(array, 2)
    
        array.Clear()
        array.Add(New Point3D(120, 60, 0))
        array.Add(New Point3D(120, 0, 0))
    
        Dim fourth As Curve = Curve.GlobalInterpolation(array, 1)
    
        array.Clear()
        array.Add(New Point3D(160, 60, 0))
        array.Add(New Point3D(160, 30, 10))
        array.Add(New Point3D(160, 0, 0))
    
        Dim fifth As Curve = Curve.GlobalInterpolation(array, 2)
    
        Dim loft As Surface = Surface.Loft(New Curve() {first, second, third, fourth, fifth}, 3)
    
        ViewportLayout1.Entities.Add(loft, Color.Aquamarine)
    
    
        ViewportLayout1.Legends(0).ColorTable = Legend.RedToBlue9
    
        loft.ComputeCurvatureMap(ViewportLayout1.Legends(0), curvatureType.Kappa1)
    
        loft.ShowCurvature = True
    
        ViewportLayout1.Legends(0).Visible = True
    End Sub

    You can display also curve curvature as shows the picture below:

    with the following code:

    protected override void OnLoad(EventArgs e) 
    { 
        List<Point3D> array = new List<Point3D>(); 
    
        array.Add(new Point3D(0, 60, 0)); 
        array.Add(new Point3D(0, 40, -5)); 
        array.Add(new Point3D(0, 20, +15)); 
        array.Add(new Point3D(0, 0, 0)); 
    
        Curve curve = Curve.GlobalInterpolation(array, 3); 
    
        viewportLayout1.Entities.Add(curve, Color.DarkBlue); 
    
        curve.ComputeCurvatureGraph(20); 
    
        curve.ShowCurvature = true; 
    }
    Protected Overrides Sub OnLoad(e As EventArgs)
        Dim array As New List(Of Point3D)()
    
        array.Add(New Point3D(0, 60, 0))
        array.Add(New Point3D(0, 40, -5))
        array.Add(New Point3D(0, 20, +15))
        array.Add(New Point3D(0, 0, 0))
    
        Dim curve__1 As Curve = Curve.GlobalInterpolation(array, 3)
    
        ViewportLayout1.Entities.Add(curve__1, Color.DarkBlue)
    
        curve__1.ComputeCurvatureGraph(20)
    
        curve__1.ShowCurvature = True
    End Sub

    Please note that function Curve.ComputeCurvatureGraph() needs a scale factor as input, necessary to define the curvature vectors length.