Ray and Construction Line (RayEnt / XLineEnt)
Less than 1 minute
Ray and Construction Line (RayEnt / XLineEnt)
Rays and construction lines are infinite-length auxiliary line entities.
RayEnt - Ray
A ray starts from a base point and extends infinitely in a specified direction.
Constructor
import { RayEnt, Point2D } from 'vjcad';
// Shorthand syntax (recommended)
const ray1 = new RayEnt([0, 0], Math.PI / 4);
// Point2D syntax
const ray2 = new RayEnt(new Point2D(0, 0), Math.PI / 4);
ray1.setDefaults();Shorthand Syntax
Both the constructor and the basePoint property support coordinates in [x, y] array format.
Properties
| Property | Type | Description |
|---|---|---|
basePoint | Point2D | Starting point of the ray |
angle | number | Direction angle (radians) |
XLineEnt - Construction Line
A construction line is a line that extends infinitely in both directions.
Constructor
import { XLineEnt, Point2D } from 'vjcad';
// Shorthand syntax (recommended)
const xline1 = new XLineEnt([50, 50], Math.PI / 6);
// Point2D syntax
const xline2 = new XLineEnt(new Point2D(50, 50), Math.PI / 6);
xline1.setDefaults();Shorthand Syntax
Both the constructor and the basePoint property support coordinates in [x, y] array format.
Properties
| Property | Type | Description |
|---|---|---|
basePoint | Point2D | A point on the construction line |
angle | number | Direction angle (radians) |
Examples
import { Engine, RayEnt, XLineEnt, Point2D } from 'vjcad';
// Create a horizontal construction line
const hLine = new XLineEnt(new Point2D(0, 50), 0);
hLine.setDefaults();
// Create a vertical construction line
const vLine = new XLineEnt(new Point2D(50, 0), Math.PI / 2);
vLine.setDefaults();
// Create a 45° ray
const ray = new RayEnt(new Point2D(0, 0), Math.PI / 4);
ray.setDefaults();
Engine.addEntities([hLine, vLine, ray]);