McNeel Wiki
How To: Create a NURBS Circle
edit · print · help · all topics
Main Pages

AccuRender

Bongo

Brazil r/s

Developer

Flamingo

Penguin

Rhino Blogs

Rhino

Rhino Labs

Search

Languages

Česky

Deutsch

English

Español

Français

Italiano

Polish

日本語

한국어

中文(繁體)

 
.
SummaryDemonstrates how to use ON_NurbsCurve to create a circle.

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;
    }

VB.NET (Rhino 4)

  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

C# (Rhino 4)

  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;
  }
rename · changes · history · subscriptions · lost and found · references · file upload