Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:sdksamples:createnurbscircle [2015/09/14] (current)
Line 1: Line 1:
 +** How To: Create a [[rhino:​nurbs|NURBs]] Circle **
 +====== ​ C++, .NET ======
 +> **Summary:​** //​Demonstrates how to use ON_NurbsCurve to create a circle.//
 +
 +===== C++ =====
 +<code c++>
 +  CRhinoCommand::​result CCommandTest::​RunCommand(
 +          const CRhinoCommandContext&​ context )
 +  {
 +    int dimension = 3;
 +    BOOL bIsRational = TRUE;
 +    int order = 3;
 +    int cv_count = 9;
 +
 +    ON_NurbsCurve nc( dimension, bIsRational,​ order, cv_count );
 +    nc.SetCV( 0, ON_4dPoint(1.0,​ 0.0, 0.0, 1.0) );
 +    nc.SetCV( 1, ON_4dPoint(0.707107,​ 0.707107, 0.0, 0.707107) );
 +    nc.SetCV( 2, ON_4dPoint(0.0,​ 1.0, 0.0, 1.0) );
 +    nc.SetCV( 3, ON_4dPoint(-0.707107,​ 0.707107, 0.0, 0.707107) );
 +    nc.SetCV( 4, ON_4dPoint(-1.0,​ 0.0, 0.0, 1.0) );
 +    nc.SetCV( 5, ON_4dPoint(-0.707107,​ -0.707107, 0.0, 0.707107) );
 +    nc.SetCV( 6, ON_4dPoint(0.0,​ -1.0, 0.0, 1.0) );
 +    nc.SetCV( 7, ON_4dPoint(0.707107,​ -0.707107, 0.0, 0.707107) );
 +    nc.SetCV( 8, ON_4dPoint(1.0,​ 0.0, 0.0, 1.0) );
 +    nc.SetKnot( 0, 0.0 );
 +    nc.SetKnot( 1, 0.0 );
 +    nc.SetKnot( 2, 0.5*ON_PI );
 +    nc.SetKnot( 3, 0.5*ON_PI );
 +    nc.SetKnot( 4, ON_PI );
 +    nc.SetKnot( 5, ON_PI );
 +    nc.SetKnot( 6, 1.5*ON_PI );
 +    nc.SetKnot( 7, 1.5*ON_PI );
 +    nc.SetKnot( 8, 2.0*ON_PI );
 +    nc.SetKnot( 9, 2.0*ON_PI );
 +
 +    if( nc.IsValid() )
 +    {
 +      context.m_doc.AddCurveObject( nc );
 +      context.m_doc.Redraw();​
 +    }
 +
 +    return CRhinoCommand::​success;​
 +  }
 +</​code>​
 +===== VB.NET =====
 +<code vb>
 +Public Overrides Function RunCommand(ByVal context As RMA.Rhino.IRhinoCommandContext)_
 +  As RMA.Rhino.IRhinoCommand.result
 +
 +  Dim dimension As Integer = 3
 +  Dim bIsRational As Boolean = True
 +  Dim order As Integer = 3
 +  Dim cv_count As Integer = 9
 +  Dim nc As New OnNurbsCurve(dimension,​ bIsRational,​ order, cv_count)
 +  nc.SetCV(0, New On4dPoint(1.0,​ 0.0, 0.0, 1.0))
 +  nc.SetCV(1, New On4dPoint(0.707107,​ 0.707107, 0.0, 0.707107))
 +  nc.SetCV(2, New On4dPoint(0.0,​ 1.0, 0.0, 1.0))
 +  nc.SetCV(3, New On4dPoint(-0.707107,​ 0.707107, 0.0, 0.707107))
 +  nc.SetCV(4, New On4dPoint(-1.0,​ 0.0, 0.0, 1.0))
 +  nc.SetCV(5, New On4dPoint(-0.707107,​ -0.707107, 0.0, 0.707107))
 +  nc.SetCV(6, New On4dPoint(0.0,​ -1.0, 0.0, 1.0))
 +  nc.SetCV(7, New On4dPoint(0.707107,​ -0.707107, 0.0, 0.707107))
 +  nc.SetCV(8, New On4dPoint(1.0,​ 0.0, 0.0, 1.0))
 +  nc.SetKnot(0,​ 0.0)
 +  nc.SetKnot(1,​ 0.0)
 +  nc.SetKnot(2,​ 0.5 * OnUtil.On_PI)
 +  nc.SetKnot(3,​ 0.5 * OnUtil.On_PI)
 +  nc.SetKnot(4,​ OnUtil.On_PI)
 +  nc.SetKnot(5,​ OnUtil.On_PI)
 +  nc.SetKnot(6,​ 1.5 * OnUtil.On_PI)
 +  nc.SetKnot(7,​ 1.5 * OnUtil.On_PI)
 +  nc.SetKnot(8,​ 2.0 * OnUtil.On_PI)
 +  nc.SetKnot(9,​ 2.0 * OnUtil.On_PI)
 +  If (nc.IsValid()) Then
 +    context.m_doc.AddCurveObject(nc)
 +    context.m_doc.Redraw()
 +  End If
 +  Return IRhinoCommand.result.success
 +End Function
 +</​code>​
 +===== C# =====
 +<code c#>
 +public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
 +{
 +  int dimension = 3;
 +  bool bIsRational = true;
 +  int order = 3;
 +  int cv_count = 9;
 +  OnNurbsCurve nc = new OnNurbsCurve(dimension,​ bIsRational,​ order, cv_count);
 +  nc.SetCV(0, new On4dPoint(1.0,​ 0.0, 0.0, 1.0));
 +  nc.SetCV(1, new On4dPoint(0.707107,​ 0.707107, 0.0, 0.707107));
 +  nc.SetCV(2, new On4dPoint(0.0,​ 1.0, 0.0, 1.0));
 +  nc.SetCV(3, new On4dPoint(-0.707107,​ 0.707107, 0.0, 0.707107));
 +  nc.SetCV(4, new On4dPoint(-1.0,​ 0.0, 0.0, 1.0));
 +  nc.SetCV(5, new On4dPoint(-0.707107,​ -0.707107, 0.0, 0.707107));
 +  nc.SetCV(6, new On4dPoint(0.0,​ -1.0, 0.0, 1.0));
 +  nc.SetCV(7, new On4dPoint(0.707107,​ -0.707107, 0.0, 0.707107));
 +  nc.SetCV(8, new On4dPoint(1.0,​ 0.0, 0.0, 1.0));
 +  nc.SetKnot(0,​ 0.0);
 +  nc.SetKnot(1,​ 0.0);
 +  nc.SetKnot(2,​ 0.5 * OnUtil.On_PI);​
 +  nc.SetKnot(3,​ 0.5 * OnUtil.On_PI);​
 +  nc.SetKnot(4,​ OnUtil.On_PI);​
 +  nc.SetKnot(5,​ OnUtil.On_PI);​
 +  nc.SetKnot(6,​ 1.5 * OnUtil.On_PI);​
 +  nc.SetKnot(7,​ 1.5 * OnUtil.On_PI);​
 +  nc.SetKnot(8,​ 2.0 * OnUtil.On_PI);​
 +  nc.SetKnot(9,​ 2.0 * OnUtil.On_PI);​
 +  if( nc.IsValid() )
 +  {
 +    context.m_doc.AddCurveObject( nc );
 +    context.m_doc.Redraw();​
 +  }
 +  return IRhinoCommand.result.success;​
 +}
 +
 +</​code>​
 +
 +
 +{{tag>​Developer}}
  
developer/sdksamples/createnurbscircle.txt ยท Last modified: 2015/09/14 (external edit)