Surfaces of revolution.
Let's create a surface of revolution. An unclosed spline will be the rotated contour.
This code creates a spline:
SG_POINT tmpPnt;
SG_SPLINE* spl2 = SG_SPLINE::Create();
tmpPnt.x = 1.0; tmpPnt.y = -3.0; tmpPnt.z = 0.0;
spl2->AddKnot(tmpPnt,0);
tmpPnt.x = 3.0; tmpPnt.y = -2.0; tmpPnt.z = 0.0;
spl2->AddKnot(tmpPnt,1);
tmpPnt.x = 2.0; tmpPnt.y = -1.0; tmpPnt.z = 0.0;
spl2->AddKnot(tmpPnt,2);
tmpPnt.x = 3.0; tmpPnt.y = 1.0; tmpPnt.z = 0.0;
spl2->AddKnot(tmpPnt,3);
tmpPnt.x = 2.0; tmpPnt.y = 4.0; tmpPnt.z = 0.0;
spl2->AddKnot(tmpPnt,4);
tmpPnt.x =4.0; tmpPnt.y = 5.0; tmpPnt.z = 0.0;
spl2->AddKnot(tmpPnt,5);
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 (0, 0, 0) and (0, -2, 0) points. The rotation angle will be 250 degrees:
SG_POINT p1 = {0,-2,0};
SG_POINT p2 = {0,0,0};
sgC3DObject* rO = (sgC3DObject*)sgKinematic::Rotation(*spl2_obj,p1,p2,250,false);
sgGetScene()->AttachObject(rO);
rO->SetAttribute(SG_OA_COLOR,3);
Then we'll move the obtained surface:
SG_VECTOR transV1 = {-1,0,0};
rO->InitTempMatrix()->Translate(transV1);
rO->ApplyTempMatrix();
rO->DestroyTempMatrix();
See also:
sgCSpline sgCSpline::Create SG_SPLINE
sgGetScene sgCScene::AttachObject sgCObject::SetAttribute
Illustration: