Click or drag to resize
SurfaceCurvatureKappa Method
Gets the Kappa curvature value.

Namespace: Rhino.Geometry
Assembly: RhinoCommon (in RhinoCommon.dll) Version: 5.1.50000.0 (5.0.20693.0)
Syntax
public double Kappa(
	int direction
)

Parameters

direction
Type: SystemInt32
Kappa index, valid values are 0 and 1.

Return Value

Type: Double
The specified kappa value.
Examples
using Rhino;
using Rhino.DocObjects;
using Rhino.Input;
using Rhino.Commands;

namespace examples_cs
{
  public class PrincipalCurvatureCommand : Command
  {
    public override string EnglishName { get { return "csPrincipalCurvature"; } }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      ObjRef obj_ref;
      var rc = RhinoGet.GetOneObject("Select surface for curvature measurement", true, 
        ObjectType.Surface, out obj_ref);
      if (rc != Result.Success)
        return rc;
      var surface = obj_ref.Surface();

      var gp = new Rhino.Input.Custom.GetPoint();
      gp.SetCommandPrompt("Select point on surface for curvature measurement");
      gp.Constrain(surface, false);
      gp.Get();
      if (gp.CommandResult() != Result.Success)
        return gp.CommandResult();
      var point_on_surface = gp.Point();

      double u, v;
      if (!surface.ClosestPoint(point_on_surface, out u, out v))
        return Result.Failure;

      var surface_curvature = surface.CurvatureAt(u, v);
      if (surface_curvature == null)
        return Result.Failure;

      RhinoApp.WriteLine("Surface curvature evaluation at parameter: ({0}, {1})", u, v);

      RhinoApp.WriteLine("  3-D Point: ({0}, {1}, {2})",
        surface_curvature.Point.X,
        surface_curvature.Point.Y,
        surface_curvature.Point.Z);

      RhinoApp.WriteLine("  3-D Normal: ({0}, {1}, {2})",
        surface_curvature.Normal.X,
        surface_curvature.Normal.Y,
        surface_curvature.Normal.Z);

      RhinoApp.WriteLine(string.Format("  Maximum principal curvature: {0} ({1}, {2}, {3})", 
        surface_curvature.Kappa(0), 
        surface_curvature.Direction(0).X, 
        surface_curvature.Direction(0).Y, 
        surface_curvature.Direction(0).Z));

      RhinoApp.WriteLine(string.Format("  Minimum principal curvature: {0} ({1}, {2}, {3})", 
        surface_curvature.Kappa(1), 
        surface_curvature.Direction(1).X, 
        surface_curvature.Direction(1).Y, 
        surface_curvature.Direction(1).Z));

      RhinoApp.WriteLine("  Gaussian curvature: {0}", surface_curvature.Gaussian);
      RhinoApp.WriteLine("  Mean curvature: {0}", surface_curvature.Mean);

      return Result.Success;
    }
  }
}
import rhinoscriptsyntax as rs

surface_id,_,_,_,_,_ = rs.GetSurfaceObject("Select surface for curvature measurement")
point = rs.GetPointOnSurface(surface_id, 
    "Select point on surface for curvature measurement")
u,v = rs.SurfaceClosestPoint(surface_id, point)

#point, normal, kappa_u, direction_u, kappa_v, direction_v, gaussian, mean =
surface_curvature = rs.SurfaceCurvature(surface_id, (u,v))

point, normal, kappa_u, direction_u, kappa_v, direction_v, gaussian, mean = surface_curvature

print "Surface curvature evaluation at parameter: ({0}, {1})".format(u,v)

print "  3-D Point: ({0}, {1}, {2})".format(point.X, point.Y, point.Z)

print "  3-D Normal: ({0}, {1}, {2})".format(normal.X, normal.Y, normal.Z)

print "  Maximum principal curvature: {0} ({1}, {2}, {3})".format(
  kappa_u, direction_u.X, direction_u.Y, direction_u.Z)

print "  Minimum principal curvature: {0} ({1}, {2}, {3})".format(
  kappa_v, direction_v.X, direction_v.Y, direction_v.Z)

print "  Gaussian curvature: {0}".format(gaussian)
print "  Mean curvature: {0}".format(mean)
See Also