Solids of revolution.

 

Let's create a solid of revolution. A closed spline will be the rotated contour.

 

This code creates a spline:

 

    SG_POINT tmpPnt;

 SG_SPLINE* spl2 = SG_SPLINE::Create();

 int fl=0;

 for (double i=0.0;i<2.0*3.14159265;i+=0.4)

 {

         tmpPnt.x = ((double)(fl%3+2))*cos(i);

         tmpPnt.y = ((double)(fl%3+2))*sin(i);

         tmpPnt.z = 0.0;

         spl2->AddKnot(tmpPnt,fl);

         fl++;

 }

 spl2->Close();

 

 sgCSpline* spl2_obj = sgCreateSpline(*spl2);

 sgGetScene()->AttachObject(spl2_obj);

 spl2_obj->SetAttribute(SG_OA_COLOR,12);

 spl2_obj->SetAttribute(SG_OA_LINE_THICKNESS,2);

 

 SG_SPLINE::Delete(spl2);

 

Let's rotate the contour around the axis lying on the (10, 10, 0) and (20, 15, 0) points. The rotation angle will be 290 degrees:

 

 SG_POINT p1 = {10,10,0};

 SG_POINT p2 = {20,15,0};

 

 sgC3DObject* rO = (sgC3DObject*)sgKinematic::Rotation(*spl2_obj,p1,p2,290,true);

 

 sgGetScene()->AttachObject(rO);

 rO->SetAttribute(SG_OA_COLOR,8);

 

Then we'll move the obtained solid:

 

  SG_VECTOR transV1 = {-6,0,0};

 rO->InitTempMatrix()->Translate(transV1);

 rO->ApplyTempMatrix();

 rO->DestroyTempMatrix();

 

 

 

See also:

sgKinematic::Rotation  

sgCSpline   sgCSpline::Create SG_SPLINE

sgGetScene sgCScene::AttachObject   sgCObject::SetAttribute

 

 

Illustration:

kin_roB