primitives-2d_rectangle.js
import {Polygon} from "./index";
import {Plane, Vector} from "../math";
/**
* Creates a rectangle based on the specified parameters.
* @memberof primitives-2D
* @alias Rectangle
* @param {Object} parameters - The parameters for the rectangle.
* @param {Plane} [parameters.plane=Plane.XY] - The plane in which the rectangle is constructed.
* @param {Vector} [parameters.center=Vector.ZERO] - The center of the rectangle.
* @param {number} parameters.width - The width of the rectangle.
* @param {number} parameters.height - The height of the rectangle.
* @returns {Face} A `Face` object representing the constructed rectangle.
*/
const Rectangle = ({plane = Plane.XY, center = Vector.ZERO, width, height}) => {
const points = [];
points.push(new Vector({x: center.x + width / 2, y: center.y + height / 2, z: center.z}));
points.push(new Vector({x: center.x - width / 2, y: center.y + height / 2, z: center.z}));
points.push(new Vector({x: center.x - width / 2, y: center.y - height / 2, z: center.z}));
points.push(new Vector({x: center.x + width / 2, y: center.y - height / 2, z: center.z}));
return Polygon({plane: plane, vertices: points});
};
export {Rectangle};