import oc from "../opencascade/initializer";
import {Vector} from "./vector";
/**
* Represents a mathematical axis in 3D space.
* @memberof math
* @alias Axis
*/
export class Axis {
#wrapped;
/**
* Creates a new `Axis` instance.
* @param {Object} parameters - The parameters for the axis.
* @param {Vector} parameters.origin - The origin of the axis.
* @param {Vector} parameters.direction - The direction of the axis.
*/
constructor({origin, direction}) {
this.#wrapped = new oc.gp_Ax1_2(new oc.gp_Pnt_3(origin.x, origin.y, origin.z), new oc.gp_Dir_4(direction.x, direction.y, direction.z));
}
/**
* Returns the wrapped OpenCascade object.
* @private
*/
get wrapped() {
return this.#wrapped;
}
/**
* Retrieves the origin of the axis.
* @returns {Vector} The origin of the axis.
*/
get origin() {
const origin = this.#wrapped.Location();
return new Vector({
x: origin.X(),
y: origin.Y(),
z: origin.Z(),
});
}
/**
* Sets the origin of the axis.
* @param {Vector} value - The new origin of the axis.
*/
set origin(value) {
this.#wrapped.SetLocation(new oc.gp_Pnt_3(value.x, value.y, value.z));
}
/**
* Retrieves the direction of the axis.
* @returns {Vector} The direction of the axis.
*/
get direction() {
const direction = this.#wrapped.Direction();
return new Vector({
x: direction.X(),
y: direction.Y(),
z: direction.Z(),
});
}
/**
* Sets the direction of the axis.
* @param {Vector} value - The new direction of the axis.
*/
set direction(value) {
this.#wrapped.SetDirection(new oc.gp_Dir_4(value.x, value.y, value.z));
}
/**
* The X-axis, with origin at `Vector.ZERO` and direction `Vector.X`.
* @type {Axis}
* @static
*/
static OX = new Axis({
origin: Vector.ZERO,
direction: Vector.X,
});
/**
* The Y-axis, with origin at `Vector.ZERO` and direction `Vector.Y`.
* @type {Axis}
* @static
*/
static OY = new Axis({
origin: Vector.ZERO,
direction: Vector.Y,
});
/**
* The Z-axis, with origin at `Vector.ZERO` and direction `Vector.Z`.
* @type {Axis}
* @static
*/
static OZ = new Axis({
origin: Vector.ZERO,
direction: Vector.Z,
});
}