Creating a Torus
We can create a torus by instantiating an Mx3dMkTorus object.
You can construct an Mx3dMkTorus object by providing a right-handed coordinate system Mx3dGeCSYSR and the radii of the torus.
typescript
// Get the document
const doc = mxcad3d.getDocument();
// The default constructed right-handed coordinate system is aligned with the world coordinate system
const csysr = new Mx3dGeCSYSR();
// Create a torus with a radius of 20 and a tube radius of 5
const torusMaker = new Mx3dMkTorus(csysr, 20, 5);
// Get the topological shape
const torusShape = torusMaker.Shape();
// Create a shape label in the document
const torusLabel = doc.addShapeLabel();
// Set the shape to the label
torusLabel.setShape(torusShape);
// Update the display (this will update the model displayed in the canvas)
mxcad3d.update();
The Mx3dMkTorus class also has additional constructors for creating incomplete tori, which are not discussed here.
typescript
constructor(Axes: Mx3dGeCSYSR, R1: number, R2: number);
constructor(Axes: Mx3dGeCSYSR, R1: number, R2: number, angle: number);
constructor(Axes: Mx3dGeCSYSR, R1: number, R2: number, angle1: number, angle2: number);
constructor(Axes: Mx3dGeCSYSR, R1: number, R2: number, angle1: number, angle2: number, angle: number);
Note
GitHub and network issues may cause slow loading times, so please be patient and allow a few minutes for the content to load.