In the discussion of my idiomatic ellipse hull graphing mastodon toot, Ksaj remembered me his summary of ellipse perimeter estimation: https://ksaj.sdf.org/ and suggested I throw it into my simple gnuplotting of ellipses. He is right that my simple common lisp gnuplot idiom should be able to graph these things together easily like: Sketch an ellipse('s hulls). Separately, calculate the perimeter from my top-and-bottom hull sketching by just summing the norms of all the vectors (something like trapz, right?). And then in the simple way, Ksaj’s cl implementations of the accurate and beautiful perimeter equations are just more lines to plot, right? I could just peg them to the X axis at the translation of the ellipse they are describing. I kind of liked the randomness of the ellipses before, so let’s still do that.
(eepitch-shell)
(setq inferior-lisp-program "sbcl")
(slime)
(setq eepitch-buffer-name "*slime-repl sbcl*")
'(did I succeed)
#|
CL-USER> '(did I succeed)
(DID I SUCCEED)
CL-USER>
|#
Great. Aside, I really like how in eev useage, you literally write what it is literally doing.
From this blog article of mine which is like
(let ((maj 3) (min 2) (rad 1) (tx 0) (ty -1))
(get-ellipse-hulls maj min rad tx ty))
Anyway, it works. I’m not going to inline the series result. It starts (highest x
value 2.3
- sorry it is right-to-left) (2.3 -0.7491398)
.
You have to go get the definition from over there.
…which is pure common lisp but declared in terms of cl-series.
Equations from Matt Parker (which is some YouTube person).
This is ksaj’s lisp except that I have written decimal versions. You will recall rotatef from the hyperspec.
(defun ellipse-perimeter-mp1 (a b)
"Input X and Y measurements of an ellipse. Output estimated perimeter."
(if (< a b)
(rotatef a b))
(* pi (- (+ (* 17.7 a)
(* 20.4 b))
(sqrt (+ (* 269 a a)
(* 667 a b)
(* 371 b b))))))
(defun ellipse-perimeter-mp2 (a b)
"Input X and Y measurements of an ellipse. Output estimated perimeter."
(if (< a b)
(rotatef a b))
(* pi (+ (* 1.2 a)
(* 0.75 b))))
And all of our ducks are in a row. All that is left is to generate a lisp of ellipses at different x
translations and their ellipse-perimeter-mp1
and ellipse-perimeter-mp2
.
Using my gnuplot from before.
(loop :repeat 10
:for maj := (1+ (1+ (/ (random 40) 10.0)))
:for min := (1+ (/
(random (* 10 (floor maj)))
10.0))
:for deg := (random 360)
:for rad := (* deg 2 pi 1/360)
:for tx := (* 2 (length mp1s))
:for ty := (random 5)
:for mp1 := (ellipse-perimeter-mp1 maj min)
:for mp2 := (ellipse-perimeter-mp2 maj min)
:nconc
(get-ellipse-hulls maj min rad tx ty)
:into ellipses
:collect (list tx mp1) :into mp1s
:collect (list tx mp2) :into mp2s
:do (print mp1s) (print mp2s)
:finally
(apply
'gnuplot "ellipses and perimeter estimates"
(append
ellipses
(list mp1s mp2s))))
Haha, somebody let Matt Parker know.
Thanks Ksaj (on the Mastodon). Obliquely, Matt Parker (Stand Up Maths).
I think talking and boosting your/the conversation on the Mastodon helps people who would like to be part of our community but do not know to find it find their way over here too. So if you would do one or either of those I would be deeply obliged.
For example, less than a thousand people seem to have found their way to my brief note from today from Kent’s interview reading his previously unpublished essay Whither Original Thought and his creation of CREF for Open University as described in AIM-829 I talked about here, when that set of memories is a big deal.