primitives-1d_three-points-arc.js
import oc from "../opencascade/initializer";
import {Edge} from "../modeling";
import {Plane, Vector} from "../math";
/**
* Creates an arc between the start and end points that goes through the through point.
* @memberof primitives-1D
* @alias ThreePointsArc
* @param {Object} parameters - The parameters for the arc.
* @param {Plane} [parameters.plane=Plane.XY] - The plane in which the arc is constructed.
* @param {Vector} parameters.start - The start point of the arc.
* @param {Vector} parameters.through - The point through which the arc must pass.
* @param {Vector} parameters.end - The end point of the arc.
* @returns {Edge} An `Edge` object representing the constructed arc.
*/
const ThreePointsArc = ({plane = Plane.XY, start, through, end}) => {
const globalStart = plane.toWorldCoordinates(new oc.gp_Pnt_3(start.x, start.y, start.z));
const globalThrough = plane.toWorldCoordinates(new oc.gp_Pnt_3(through.x, through.y, through.z));
const globalEnd = plane.toWorldCoordinates(new oc.gp_Pnt_3(end.x, end.y, end.z));
const arc = new oc.GC_MakeArcOfCircle_4(globalStart, globalThrough, globalEnd).Value();
const handle = new oc.Handle_Geom_Curve_2(arc.get());
return new Edge(new oc.BRepBuilderAPI_MakeEdge_24(handle).Edge());
};
export {ThreePointsArc};