kaveh808 / kons-9

Common Lisp 3D Graphics Project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

implement 3-point arc curve

kaveh808 opened this issue · comments

In kernel/curve.lisp, implement the function:

(defun make-3-point-arc (p0 p1 p2 num-segments)
  ...)
commented

@kaveh808 Sorry it's been so long since I've touched this. Life has been very demanding as of late. I was able to take a look at curve.lisp and I have have developed a fairly good understanding of what's going on. My first attempt at making a 3-point curve is to evoke make-line-curve for points p0 to p1 and then from p1 to p2. Using the example from other curve functions I have this so far:

(defun make-3-point-arc (p0 p1 p2 num-segments)
  (make-curve (make-line-curve p0 p1 num-segments ... )
    ))

However, I know I'm missing something. I'm not exactly sure how to use make-curve since I'm pretty new to CLOS. Any hints at where I should go from here or if my start might be off in some important way?

No worries @kaiwulf. Life has a way of doing that.

What I would suggest is computing the diameter and start/end angles of the curve from the 3 points and then calling make-arc-curve.

Something like googling 3 point circle arc may help with the math.

So something like:

(defun make-3-point-arc (p0 p1 p2 num-segments)
  (let ((d <calculate diameter>)
        (theta1 <calculate start angle>)
        (theta2 <calculate end angle>))
    (make-arc-curve d theta1 theta2 num-segments)))