Currently, I am importing a CAD file from a DXF format and I am looking for a way to draw an arc between two arbitrary points with a bulge value. My approach involves using THREE.Line to create segments of the arc.
This resource outlines some of the essential calculations in LISP, but it lacks detailed explanations regarding the center-point calculation. Additionally, I am unsure about the functionality of the angle
function in the provided example code (potentially the angle between two points using 0,0 as the origin?). The code snippet in question is as follows:
;; Bulge to Arc - Lee Mac
;; p1 - start vertex
;; p2 - end vertex
;; b - bulge
;; Returns: (<center> <start angle> <end angle> <radius>)
(defun LM:Bulge->Arc ( p1 p2 b / a c r )
(setq a (* 2 (atan b))
r (/ (distance p1 p2) 2 (sin a))
c (polar p1 (+ (- (/ pi 2) a) (angle p1 p2)) r)
)
(if (minusp b)
(list c (angle c p2) (angle c p1) (abs r))
(list c (angle c p1) (angle c p2) (abs r))
)
)
While I comprehend the calculation of a
(theta) and r
(radius), I am struggling with understanding the process of determining the center-point, which I believe is crucial for segmenting my arc accurately. If anyone could shed light on the mathematical concepts involved and possibly offer some JavaScript code, I would greatly appreciate it.