primitives-3d_cylinder.js
import oc from "../opencascade/initializer";
import {Solid} from "../modeling";
import {Plane, Vector} from "../math";
/**
* Creates a cylinder based on the specified parameters.
* @memberof primitives-3D
* @alias Cylinder
* @param {Object} parameters - The parameters for the cylinder.
* @param {Plane} [parameters.plane=Plane.XY] - The plane in which the cylinder is constructed.
* @param {Vector} [parameters.center=Vector.ZERO] - The center of the cylinder.
* @param {number} parameters.radius - The radius of the cylinder's base.
* @param {number} parameters.height - The height of the cylinder.
* @returns {Solid} A `Solid` object representing the constructed cylinder.
*/
const Cylinder = ({plane = Plane.XY, center = Vector.ZERO, radius, height}) => {
const axis = plane.wrapped.Position().Ax2();
const localOffset = plane.toWorldCoordinates(center.subtract(new Vector({z: height / 2})).wrapped);
return new Solid(new oc.BRepPrimAPI_MakeCylinder_3(axis, radius, height).Shape()).translate(new Vector({wrapped: localOffset}));
};
export {Cylinder};