MoI discussion forum
MoI discussion forum

Full Version: Cartesian Oval script

From: bemfarmer
12 Dec 2023   [#1]
OpticalOval script, by Brian McMillin, 12/04/2023.

This script creates two 2D oval curves, known as Cartesian oval(s), in the Front View. The smaller oval has special optical properties, because it is a Rigorously Stigmatic Surface (RSS). The straightforward math operations become complicated, and touch on complex numbers. Optical terminology may be unfamiliar.

Main link, "Silva-Torres"):
https://www.researchgate.net/publication/339682924_Explicit_Cartesian_oval_as_a_superconic_surface_for_stigmatic_imaging_optical_systems_with_real_or_virtual_source_or_image

To calculate and plot the ovals, Alberto Silva wrote a python program to parametrically plot these two ovals.
Silva Python code link: https://figshare.com/articles/code/Full_Cartesian_surfaces/11763936

For a computer set up property to run python, (e.g. python3x), running the python program will show the two ovals on the computer screen. But the goal is to plot the curves in MoI. A portion of the python program was translated and adapted to javascript.
The optical parameters, ( zo, zi ) are inverted to ( zeta_o and zeta_i). A for loop with angle(s) phi is set up.
The 4 optical parameters, ( no, ni, zeta_o, zeta_i ), are used to calculate the 4 shape parameters ( K, c_0, c2, b2 ).
( Note that c2 and b2 are renamed from c_1 and b_1 to avoid confusion of coefficients. ) ( The shape parameters had multiple different names in companion papers. )

The 4 shape parameters, and current angle phi, are passed to a modified Mosi's javascript function cardano( K, c_0, c2, b2, phi ).
The 3 coefficients and constant of the of cubic equation, ( a1, b1, c1, and d1 ), are calculated from the 4 shape parameters and current phi. The cubic equation is: a1*rho^3 + b1*rho^2 + c1*rho + d1 = 0.
Division by a1 is performed, and new coefficients a, b, c are assigned. The new cubic equation is rho^3 + a*rho^2 + b*rho + c = 0. etcetera.
The cardano function calculates the real root value(s) of rho.

For the buildtype "optical_oval", the real root rho3 is returned.

Back to the "python javascript", the cartesian coordinates of the current angle is calculated, from rho3. rho3 is the current hypotenuse length, at current angle phi. Using front view in MoI, with default x,y,z labels for the 3 axi, the optical meridional frame is mimicked.
The MoI-x-axis coordinate is rho3 * Math.cos(phi). ( This is the papers meridional z-axis. )
The MoI-y-axis coordinate is zero.
The MoI-z-axis coordinate is rho3 * Math.sin(phi). ( This is the papers "r" axis. )
(It is possible in MoI to reset the axi labels, but this was not done.)

Angle phi varies from 0 to PI.

The Mosi's Math link has excellent explanations, and a cubic root function.
Mosi's math link.
https://www.mosismath.com/Cardano/Cardano.html
Cardano solver in javascript:
https://www.mosismath.com/Solver/CardanoSolver.html

The index of refraction depends upon physics. Holding the outer index of refraction to a value of 1.0, (vacuum or ~air), makes sense. The inner index of refraction is greater than the outer index.

The inner focal distance coordinate (x) should be positive.
The outer focal point can be located at -x value, to left of origin, and can even be a very large negative number. (e.g ~ negative infinity)
Or it can be located to the right. (e.g ~ positive infinity)

There seem to be some dead combinations of these 4 parameters, currently.

Clicking on a index name or focus name activates a preset value.

There are other links to optical papers.

This script required a lot of study...

- Brian

The portion of smaller curves near the origin in Front view are not visible,
but are visible in Top or 3d views. I'll assume that this is a display artifact.

Attachments:
_OpticalOval01.zip