Ellipse Entity (EllipseEnt)
Less than 1 minute
Ellipse Entity (EllipseEnt)
EllipseEnt represents an ellipse entity in CAD, defined by a center point, major axis, minor axis, and rotation angle.
Overview
An ellipse is a type of conic curve widely used in engineering design. EllipseEnt supports both full ellipses and elliptical arcs.
Constructor
import { EllipseEnt, Point2D } from 'vjcad';
// Shorthand notation (recommended)
const ellipse1 = new EllipseEnt([100, 100], 50, 30, 0);
// Point2D notation
const ellipse2 = new EllipseEnt(new Point2D(100, 100), 50, 30, 0);
ellipse1.setDefaults();Shorthand Notation
Both the constructor and the center property support coordinates in [x, y] array form, avoiding the need to write new Point2D(...) every time.
Properties
| Property | Type | Description |
|---|---|---|
center | Point2D | Ellipse center point |
majorRadius | number | Major axis radius |
minorRadius | number | Minor axis radius |
majorAxis | number | Major axis angle (radians) |
rotation | number | Rotation angle (alias for majorAxis) |
startAngle | number | Start angle (elliptical arc, radians) |
endAngle | number | End angle (elliptical arc, radians) |
isEllipse | boolean | Whether it is a full ellipse (read-only) |
Examples
Full Ellipse
import { Engine, EllipseEnt } from 'vjcad';
// Create an ellipse (supports [x, y] array form)
const ellipse = new EllipseEnt([50, 50], 40, 20, 0); // center, major radius, minor radius, rotation angle
ellipse.setDefaults();
Engine.addEntities(ellipse);
console.log('Center:', ellipse.center);
console.log('Major radius:', ellipse.majorRadius);
console.log('Minor radius:', ellipse.minorRadius);Elliptical Arc
import { Engine, EllipseEnt } from 'vjcad';
// Create an elliptical arc (upper half)
const ellipseArc = new EllipseEnt([50, 80], 40, 20, 0);
ellipseArc.startAngle = 0;
ellipseArc.endAngle = Math.PI; // 180 degrees
ellipseArc.setDefaults();
Engine.addEntities(ellipseArc);
// Rotated elliptical arc
const rotatedArc = new EllipseEnt([150, 80], 40, 20, Math.PI / 6); // rotated 30 degrees
rotatedArc.startAngle = Math.PI / 4;
rotatedArc.endAngle = Math.PI * 5 / 4; // from 45 degrees to 225 degrees
rotatedArc.setDefaults();
Engine.addEntities(rotatedArc);