Easter 2024: Dinosaur Eggs, Kinder Surprise, Drug Capsules, Jumping Beans Toy and Retro programming

Oh my God. Do you know what this is? This is a dinosaur egg. The dinosaurs are breeding.

Dr. Alan Grant, Jurassic Park movie (1993)

We are again approaching Easter time and, as tradition, I would like to celebrate with an article dedicated to the most perfect thing in nature: the egg. I came across interesting books about the discovery of dinosaur eggs last year. Dinosaurs are the ancestors of birds and modern reptiles, so we will take a little detour from the traditional Easter egg, and with the spirit of equal opportunity justice, we will look at the shape of these.

I looked at the available model reported in the literature and the one that caught my attention was based on Preston’s equation[1], the first mathematical model used to describe the shape of bird eggs. The general equation is given by the following parametric expression:

\begin{cases} x = a\sin(\theta) \\ y = b\cos(\theta)(1 +c_1\sin(\theta)+  c_2\sin^2(\theta)) \end{cases} \quad \text{for } \theta \in [0^\circ, 360^\circ]

For eggs of a few birds, whose ends are virtually alike, the parameter c_1 is null. This type of geometry is common in reptile eggs and, in this reduced form, the equation was applied to study them by Maritz and Douglas [2].

This particular geometry is called a bicone and it resembles the shape of a drug capsule or container or a jumping bean toy. It is also very similar to the container of the toy hidden inside the Kinder Surprise chocolate eggs. Last year, for my traditional Easter 2023 post, I explored the geometry of squared eggs and I found a connection to the transformation of hard-boiled chicken eggs into squared ones using a kitchen tool.

For Easter 2024, I would like to propose a recreational computing exploration of the Preston parametric equation and accomplish the transformation from a biconical shape to a chicken egg shape. The source code is in the Appendix and it is written in QB64 Basic (Phenix version), which I have also used in other posts on retro programming. This program is designed to visualize the transformation of a biconical shape, resembling a bird or reptile egg, into a more typical chicken egg shape using Preston’s parametric equations. It utilizes QB64’s graphics capabilities to plot the shapes and demonstrate the transformation process on a 600×600 pixel graphics screen. The program starts by plotting the main shape of the egg using Preston’s equations. Then, it iteratively adjusts the parameters to transform the shape and plots the resulting egg at different scales. Finally, it displays a large message “Happy Easter 2024!” at the bottom of the screen using a specified font and size.

Here is the output using the parameters given in the program. Qualitatively it resembles a section of Kinder Surprise (R) chocolate eggs, but I think proportions and shape need to be checked if you managed to measure them before your kids take possession of it!

REFERENCES

  1. Preston, F.W., 1953. The shapes of birds’ eggs. The Auk70(2), pp.160-182.
  2. Maritz, M.F. and Douglas, R.M., 1994. Shape quantization and the estimation of volume and surface area of reptile eggs. Journal of Herpetology, pp.281-291.

APPENDIX

' Retro Easter Egg Transformation Program
' Author: Danilo Roccatano
' Date: March 2024
'
' Purpose:
'
' Preston's equation[1], the first mathematical model used to describe the shape of bird eggs.
' The general equation is given by the following parametric expression:
'
'   x = a * sin(theta)
'   y = b * cos(theta) * (1 + c1 * sin(theta) + c2 * sin^2(theta))
'
' The program transform the biconical shape a the center of a choccolate egg
' to the shape of a common fowl egg (the parameter are taken from Preston [1].
'
' References:
' [1] Preston, F.W., 1953. The shapes of birds' eggs. The Auk, 70(2), pp.160-182.' [2] Maritz, M.F. and Douglas, R.M., 1994. Shape quantization and the estimation of volume and surface area of reptile eggs. Journal of Herpetology, pp.281-291.
'

' Set up 600x600 graphics screen
Screen _NewImage(600, 600, 256)

' Constants and parameters
Const pi = 3.14159265358979
Dim a, b, c, theta_step
a = 155 ' half-Length of the chocolate egg
b = 121 ' half-diameter of the chocolate egg
c = 0. ' Change these values as needed
s = 0.5 ' MD scaling factor
c1 = -0.0797
c2 = -0.0351
c3 = 0.5
theta_step = 1 ' Change this value to increase or decrease the number of plotted points
co = 14

' Plotting the main shape of the egg
For theta = 0 To 360 Step theta_step
    Call PrestonEquations(theta, a, b, c, c3, x, y)
    x_screen = 300 + x * s
    y_screen = 300 - y * s
    y_screen1 = 300 + y * s
    x_screen1 = 300 - x * s

    If x_screen >= 0 And x_screen <= 599 And y_screen >= 0 And y_screen <= 599 Then
        Line (y_screen1, x_screen)-(y_screen, x_screen), co
    End If
Next

' Adjusting parameters for further transformation
c = c - 0.01594
c3 = c3 - 0.10702
co = 15

' Plotting the transformation
For s = 0.6 To 1.0 Step 0.1
    For theta = 0 To 360 Step theta_step
        Call PrestonEquations(theta, a, b, c, c3, x, y)
        Call PlotPoint(y, x, s, co) ' Plot points for MDEquations
        ' External chocolate egg contour
        Call PrestonEquations(theta, a, b, c1, c2, x, y)
        Call PlotPoint(y, x, 1, 6) ' Plot points for PrestonEquations
    Next
    c = c - 0.01594
    c3 = c3 - 0.10702
Next
Call DrawHappyEaster
' Wait for a keypress to exit
Do
Loop Until InKey$ <> ""
End

' Subroutine to calculate parametric equations for MDEquations
Sub MDEquations (theta, a, b, c, x, y)
    thetar = theta * pi / 180
    x = a * Cos(thetar)
    y = b * Sin(thetar) * (1 + c * Cos(thetar) ^ 2)
End Sub

' Subroutine to calculate parametric equations for PrestonEquations
Sub PrestonEquations (theta, a, b, c1, c2, x, y)
    thetar = theta * pi / 180
    x = a * Sin(thetar)
    y = b * Cos(thetar) * (1 + c1 * Sin(thetar) + c2 * Sin(thetar) ^ 2)
End Sub

' Subroutine to plot points
Sub PlotPoint (x, y, s_factor, col)
    x_screen = 300 + x * s_factor
    y_screen = 300 - y * s_factor ' Adjust if necessary
    If x_screen >= 0 And x_screen <= 599 And y_screen >= 0 And y_screen <= 599 Then
        Line (x_screen, y_screen)-(x_screen + 1, y_screen + 1), col, BF ' Plot points
    End If
End Sub
' Subroutine to draw "Happy Easter 2024!" using PRINT
Sub DrawHappyEaster ()
    ' Print the ASCII art
    Locate 30, 1
    Print "          _   _                           _____          _            "
    Print "         | | | | __ _ _ __  _ __  _   _  | ____|__ _ ___| |_ ___ _ __ "
    Print "         | |_| |/ _` | '_ \| '_ \| | | | |  _| / _` / __| __/ _ \ '__|"
    Print "         |  _  | (_| | |_) | |_) | |_| | | |__| (_| \__ \ ||  __/ |   "
    Print "         |_| |_|\__,_| .__/| .__/ \__, | |_____\__,_|___/\__\___|_|   "
    Print "                     |_|   |_|    |___/                               "
    Print "                              ____   ___ ____  _  _                   "
    Print "                             |___ \ / _ \___ \| || |                  "
    Print "                               __) | | | |__) | || |_                 "
    Print "                              / __/| |_| / __/|__   _|                "
    Print "                             |_____|\___/_____|  |_|                  "

End Sub

One thought on “Easter 2024: Dinosaur Eggs, Kinder Surprise, Drug Capsules, Jumping Beans Toy and Retro programming

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.