technical notes for the raytracing of toroidal surfaces

14
Johannes StΓΆrkle, 2020-03-18 1 Technical Notes for the Raytracing of Toroidal Surfaces Table of Contents Technical Notes for the Raytracing of Toroidal Surfaces ............................................................................... 1 Introduction ................................................................................................................................................. 2 Toroidal Surface Description ....................................................................................................................... 3 Range of x & y for Solutions at Real Numbers ............................................................................................ 5 Normal Vector of Toroidal Surface .............................................................................................................. 6 Intersection of a Ray and a Torus ............................................................................................................... 8 Special Case: Cylinder Lens ..................................................................................................................... 10 Cylinder-Line Intersection ......................................................................................................................... 10 Parametrical Toroidal Surface Description................................................................................................ 12 Practical Example with MATLAB ............................................................................................................... 12 Attachement .............................................................................................................................................. 13

Upload: others

Post on 06-Jun-2022

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 1

Technical Notes for the Raytracing of Toroidal Surfaces

Table of Contents Technical Notes for the Raytracing of Toroidal Surfaces ............................................................................... 1

Introduction ................................................................................................................................................. 2

Toroidal Surface Description ....................................................................................................................... 3

Range of x & y for Solutions at Real Numbers ............................................................................................ 5

Normal Vector of Toroidal Surface .............................................................................................................. 6

Intersection of a Ray and a Torus ............................................................................................................... 8

Special Case: Cylinder Lens ..................................................................................................................... 10

Cylinder-Line Intersection ......................................................................................................................... 10

Parametrical Toroidal Surface Description ................................................................................................ 12

Practical Example with MATLAB ............................................................................................................... 12

Attachement .............................................................................................................................................. 13

Page 2: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 2

Introduction In geometry, a torus is a surface of revolution generated by revolving a circle in three-dimensional space

about an axis that is coplanar with the circle.

In optics, a toroidal surface is described with the circle radius π‘Ÿπ‘₯ and the distance 𝑅𝑦 to the 𝑦-axis, known as

the radius of rotation.

According to ZEMAX, the curve in the Y-Z plane is defined by

𝑧π‘₯=0 =

1π‘Ÿπ‘₯𝑦2

1 + √1 βˆ’ (1 + πœ…)1π‘Ÿπ‘₯2 𝑦

2

+ 𝛼1𝑦2 + 𝛼2𝑦

4 +β‹― , (1)

where πœ… is the conic constant with respect to the 𝑦-direction. However, the complete three-dimensional

formulation is not given in [Zemax11]1. The toroidal surface is shown in Figure 1, whereby the blue curve

indicates the curve given by equation (1).

Figure 1: Toroidal Surface with the circle radius π‘Ÿπ‘₯ and the radius of rotation 𝑅𝑦

1 [Zemax11] Zemax: Zemax Optical Design Program - User's Manual. Radiant ZEMAX LLC, 2011.

𝑅𝑦

π‘Ÿπ‘₯

Page 3: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 3

Toroidal Surface Description If the radii in the range of 0 ≀ π‘Ÿπ‘₯ ≀ 𝑅𝑦, the toroidal surface in three-dimensional space without a conic

constant can be described with

𝑧 = 𝑅𝑦 βˆ’βˆš(𝑅𝑦 βˆ’ π‘Ÿπ‘₯ + βˆšπ‘Ÿπ‘₯2 βˆ’ 𝑦2)

2

βˆ’ π‘₯2

as given in [Gross05]2. In order to derive the three-dimensional formulation with a conic constant, one can

first regard the curve within the y-z plane (π‘₯ = 0) it yields

𝑧 = 𝑅𝑦 βˆ’ (𝑅𝑦 βˆ’ π‘Ÿπ‘₯ + βˆšπ‘Ÿπ‘₯2 βˆ’ 𝑦2) = π‘Ÿπ‘₯ βˆ’βˆšπ‘Ÿπ‘₯

2 βˆ’ 𝑦2

The last formulation is similar to the description of a spherical surface 𝑧Sphere = 𝑅𝑖 βˆ’ βˆšπ‘…π‘–2 βˆ’ 𝜌2.

Furthermore, the introduction of the conic constant leads to

𝑧conicSphere =1

1 + πœ…(𝑅𝑖 βˆ’ βˆšπ‘…π‘–

2 βˆ’ (1 + πœ…)𝜌2) =𝜌2

𝑅𝑖 + βˆšπ‘…π‘–2 βˆ’ (1 + πœ…)𝜌2

=

1π‘…π‘–πœŒ2

1 + √1 βˆ’ (1 + πœ…)1𝑅𝑖2 𝜌

2

as derived in [Stoerkle18]3. Hereby, 𝜌 is the radial coordinate and a binominal expansion is used for the

arrangement. The last result has the same structure as the first term in equation (1). Thus, the formulation

of the conic toroidal surface results in analogy

𝑧 = 𝑅𝑦 βˆ’βˆš(𝑅𝑦 +1

1 + πœ…(βˆ’π‘Ÿπ‘₯ + βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2))

2

βˆ’ π‘₯2.

This can be generalized to values of π‘Ÿπ‘₯ ∈ ℝ and 𝑅𝑦 ∈ ℝ with

𝑧 = 𝑅𝑦 βˆ’ sign(π‘Ÿπ‘₯)√(𝑅𝑦 +1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

2

βˆ’ π‘₯2 ,

if |𝑅𝑦| β‰₯ |π‘Ÿπ‘₯

1 + πœ…| and π‘Ÿπ‘₯ β‰₯ 0 , or |𝑅𝑦| ≀ |

π‘Ÿπ‘₯1 + πœ…

| and π‘Ÿπ‘₯ ≀ 0

(2)

and

𝑧 = 𝑅𝑦 βˆ’ sign(π‘Ÿπ‘₯)√(𝑅𝑦 +1

1 + πœ…(βˆ’βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

2

βˆ’ π‘₯2

if |𝑅𝑦| < |π‘Ÿπ‘₯

1 + πœ…| and π‘Ÿπ‘₯ > 0 , or |𝑅𝑦| > |

π‘Ÿπ‘₯1 + πœ…

| and π‘Ÿπ‘₯ < 0 .

(3)

In order to keep the vertex at the origin, i.e. 𝑧(0,0) = 0, a constant 𝑧-shift must be applied. This can be

formulated for the following cases,

If 𝑅𝑦 β‰₯π‘Ÿπ‘₯

1+πœ…

If π‘…π‘¦π‘Ÿπ‘₯ β‰₯ 0

𝑧corr = 𝑧 (4)

2 [Gross05] Gross, H. (Ed.): Handbook of Optical Systems Vol. 1 - Fundamentals of Technical Optics. Weinheim: Wiley-VCH Verlag, 2005. (see also PPT IAP Jena) 3 [Stoerkle18] StΓΆrkle, J.: Dynamic Simulation and Control of Optical Systems. No. 58 in Dissertation, Schriften aus dem Institut fΓΌr Technische und Numerische Mechanik der UniversitΓ€t Stuttgart. Shaker Verlag, Aachen (2018). Shaker Verlag

Page 4: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 4

If π‘…π‘¦π‘Ÿπ‘₯ < 0

𝑧corr = 𝑧 βˆ’ 2𝑅

(5)

If 𝑅𝑦 <π‘Ÿπ‘₯

1+πœ…

If π‘…π‘¦π‘Ÿπ‘₯ β‰₯ 0

𝑧corr = 𝑧 + 2 (π‘Ÿπ‘₯

1 + πœ…βˆ’ 𝑅) (6)

If π‘…π‘¦π‘Ÿπ‘₯ < 0

𝑧corr = 𝑧 + 2 (π‘Ÿπ‘₯

1 + πœ…βˆ’ 𝑅) βˆ’ 2𝑅 (7)

Page 5: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 5

Range of x & y for Solutions at Real Numbers In order to avoid complex results for 𝑧, the range of the π‘₯- and 𝑦-coordinates can be limited. Therefore, the

terms under the square roots of to equation (2) are considered. For the term within the inner square root it

results

π‘Ÿπ‘₯2 βˆ’ (1 + πœ…)𝑦2 β‰₯ 0

π‘Ÿπ‘₯2

(1 + πœ…)β‰₯ 𝑦2

βˆ’|π‘Ÿπ‘₯|

√1 + πœ…β‰€ 𝑦 ≀

|π‘Ÿπ‘₯|

√1 + πœ…

(8)

If 𝑅𝑦 β‰  0, the outer square root results with real values for

(𝑅𝑦 +1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

2

β‰₯ π‘₯2

|𝑅𝑦 +1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯)| β‰₯ |π‘₯|

A more conservative estimation leads to

||𝑅𝑦| +1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ |π‘Ÿπ‘₯|)| β‰₯ |π‘₯|.

Page 6: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 6

Normal Vector of Toroidal Surface The surface description given by equation (2) can also be interpreted as a zero-isoplane at the potential

𝑉(π‘₯, 𝑦, 𝑧) , which is also called implicit surface representation

𝑉(π‘₯, 𝑦, 𝑧) = 𝑅𝑦 βˆ’ sign(π‘Ÿπ‘₯)√(𝑅𝑦 +1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

2

βˆ’ π‘₯2 βˆ’ 𝑧 = 0

if |𝑅𝑦| β‰₯ |π‘Ÿπ‘₯

1 + πœ…| and π‘Ÿπ‘₯ β‰₯ 0 , or |𝑅𝑦| ≀ |

π‘Ÿπ‘₯1 + πœ…

| and π‘Ÿπ‘₯ ≀ 0 .

(9)

Thereby, the gradient is equal to the direction 𝑛𝑖 of the unit vector, which is orthogonal

to the surface.

𝒏 = grad(𝑉(π‘₯, 𝑦, 𝑧)) = [πœ•π‘‰

πœ•π‘₯

πœ•π‘‰

πœ•π‘¦

πœ•π‘‰

πœ•π‘§ ]𝑇

At first, the partial derivative in the π‘₯-direction leads to

πœ•π‘‰

πœ•π‘₯= βˆ’

1

2sign(π‘Ÿπ‘₯)((𝑅𝑦 +

1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

2

βˆ’ π‘₯2)

βˆ’12

(βˆ’2π‘₯)

= sign(π‘Ÿπ‘₯)π‘₯

√(𝑅𝑦 +1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

2

βˆ’ π‘₯2

= 𝑧π‘₯ .

Second, the partial derivative in the 𝑦-direction leads to

πœ•π‘‰

πœ•π‘¦= βˆ’

1

2sign(π‘Ÿπ‘₯)

(

(𝑅𝑦 +

1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

2

βˆ’ π‘₯2

⏟ 𝑒(π‘₯,𝑦) )

βˆ’12

πœ•π‘’1(π‘₯, 𝑦)

πœ•π‘¦ ,

where

πœ•π‘’1(π‘₯, 𝑦)

πœ•π‘¦= 2 (𝑅𝑦 +

1

1 + πœ…(π‘Ÿπ‘₯2 βˆ’ (1 + πœ…)𝑦2)

12 βˆ’

π‘Ÿπ‘₯1 + πœ…

)πœ•π‘’2(π‘₯, 𝑦)

πœ•π‘¦

and where

πœ•π‘’2(π‘₯, 𝑦)

πœ•π‘¦=

1

2(1 + πœ…)(π‘Ÿπ‘₯2 βˆ’ (1 + πœ…)𝑦2)βˆ’

12 (βˆ’2(1 + πœ…)𝑦)

As a consequence, it follows

πœ•π‘‰

πœ•π‘¦= βˆ’

1

2sign(π‘Ÿπ‘₯)

(

(𝑅𝑦 +

1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

2

βˆ’ π‘₯2

⏟ 𝑒(π‘₯,𝑦) )

βˆ’12

…

2 (𝑅𝑦 +1

1 + πœ…(π‘Ÿπ‘₯2 βˆ’ (1 + πœ…)𝑦2)

12 βˆ’

π‘Ÿπ‘₯1 + πœ…

)1

2(1 + πœ…)(π‘Ÿπ‘₯2 βˆ’ (1 + πœ…)𝑦2)βˆ’

12 (βˆ’2(1 + πœ…)𝑦)

= sign(π‘Ÿπ‘₯)

𝑦 (𝑅𝑦 +1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

βˆšπ‘Ÿπ‘₯2 βˆ’ (1 + πœ…)𝑦2 √(𝑅𝑦 +

11 + πœ…

(βˆšπ‘Ÿπ‘₯2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

2

βˆ’ π‘₯2

= 𝑧𝑦

Third, the partial derivative in the 𝑦-direction results with πœ•π‘‰

πœ•π‘§= βˆ’1

Page 7: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 7

In contrast, the partial derivatives for the cases

if |𝑅𝑦| < |π‘Ÿπ‘₯

1 + πœ…| and π‘Ÿπ‘₯ > 0 , or |𝑅𝑦| > |

π‘Ÿπ‘₯1 + πœ…

| and π‘Ÿπ‘₯ < 0

results with πœ•π‘‰

πœ•π‘₯= sign(π‘Ÿπ‘₯)

π‘₯

√(𝑅𝑦 +1

1 + πœ…(βˆ’βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

2

βˆ’ π‘₯2

= 𝑧π‘₯ .

πœ•π‘‰

πœ•π‘¦= sign(π‘Ÿπ‘₯)

𝑦 (𝑅𝑦 +1

1 + πœ…(βˆ’βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

βˆ’βˆšπ‘Ÿπ‘₯2 βˆ’ (1 + πœ…)𝑦2 √(𝑅𝑦 +

11 + πœ…

(βˆ’βˆšπ‘Ÿπ‘₯2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

2

βˆ’ π‘₯2

= 𝑧𝑦

Finally, the normal unit vector results with

οΏ½ΜƒοΏ½ =1

√1 + 𝑧π‘₯2 + 𝑧𝑦

2

[

βˆ’π‘§π‘₯βˆ’π‘§π‘¦1] .

Page 8: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 8

Intersection of a Ray and a Torus The intersection of a ray with a surface can be defined by the line

𝒓𝑖 = π’“π‘–βˆ’1 + π‘Žπ‘–π’…π‘–βˆ’1 = [

π‘Ÿπ‘–βˆ’1,π‘₯π‘Ÿπ‘–βˆ’1,π‘¦π‘Ÿπ‘–βˆ’1,𝑧

] + π‘Žπ‘– [

π‘‘π‘–βˆ’1,π‘₯π‘‘π‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑧

], (10)

which starts at the former intersection point (or starting point) π’“π‘–βˆ’1,by the ray direction π’…π‘–βˆ’1and the by

distance π‘Žπ‘– between the intersection points. During the ray tracing, this unknown distance π‘Žπ‘– must be

computed.

The toroidal surface according to equation (2) can be rearranged to

(𝑧 βˆ’ 𝑅𝑦)2= (𝑅𝑦 +

1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯))

2

βˆ’ π‘₯2

and the line equation (10) can be insert, which leads to

(π‘Ÿπ‘–βˆ’1,𝑧 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑧 βˆ’ 𝑅𝑦)2= (𝑅𝑦 +

1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑦)2 βˆ’ π‘Ÿπ‘₯))

2

βˆ’ (π‘Ÿπ‘–βˆ’1,π‘₯ + π‘Žπ‘–π‘‘π‘–βˆ’1,π‘₯)2

(π‘Ÿπ‘–βˆ’1,𝑧 βˆ’ 𝑅𝑦 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑧)2= (𝑅𝑦 +

1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑦)2βˆ’ π‘Ÿπ‘₯))

2

βˆ’β‹―

(π‘Ÿπ‘–βˆ’1,π‘₯2 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘₯π‘‘π‘–βˆ’1,π‘₯ + π‘Žπ‘–

2π‘‘π‘–βˆ’1,π‘₯2 )

((π‘Ÿπ‘–βˆ’1,𝑧 βˆ’ 𝑅𝑦)2+ 2π‘Žπ‘–(π‘Ÿπ‘–βˆ’1,𝑧 βˆ’ 𝑅𝑦)π‘‘π‘–βˆ’1,𝑧 + π‘Žπ‘–

2π‘‘π‘–βˆ’1,𝑧2 )

= 𝑅𝑦2 + 2𝑅𝑦

1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑦)2βˆ’ π‘Ÿπ‘₯)

+1

(1 + πœ…)2(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑦)2βˆ’ π‘Ÿπ‘₯)

2

βˆ’ (π‘Ÿπ‘–βˆ’1,π‘₯2 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘₯π‘‘π‘–βˆ’1,π‘₯ + π‘Žπ‘–

2π‘‘π‘–βˆ’1,π‘₯2 )

((π‘Ÿπ‘–βˆ’1,𝑧 βˆ’ 𝑅𝑦)2+ 2π‘Žπ‘–(π‘Ÿπ‘–βˆ’1,𝑧 βˆ’ 𝑅𝑦)π‘‘π‘–βˆ’1,𝑧 + π‘Žπ‘–

2π‘‘π‘–βˆ’1,𝑧2 ) + (π‘Ÿπ‘–βˆ’1,π‘₯

2 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘₯π‘‘π‘–βˆ’1,π‘₯ + π‘Žπ‘–2π‘‘π‘–βˆ’1,π‘₯

2 )

= 𝑅𝑦2 βˆ’ 2𝑅𝑦

1

1 + πœ…π‘Ÿπ‘₯ + 2𝑅𝑦

1

1 + πœ…βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑦)2

+1

(1 + πœ…)2(π‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑦)2βˆ’ 2π‘Ÿπ‘₯βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑦)2+ π‘Ÿπ‘₯

2)

(π‘Ÿπ‘–βˆ’1,𝑧2 βˆ’ 2π‘Ÿπ‘–βˆ’1,𝑧𝑅𝑦 + 𝑅𝑦

2 + 2π‘Žπ‘–(π‘Ÿπ‘–βˆ’1,𝑧 βˆ’ 𝑅𝑦)π‘‘π‘–βˆ’1,𝑧 + π‘Žπ‘–2π‘‘π‘–βˆ’1,𝑧

2 ) + (π‘Ÿπ‘–βˆ’1,π‘₯2 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘₯π‘‘π‘–βˆ’1,π‘₯ + π‘Žπ‘–

2π‘‘π‘–βˆ’1,π‘₯2 ) βˆ’ 𝑅𝑦

2

+ 2𝑅𝑦1

1 + πœ…π‘Ÿπ‘₯ βˆ’

1

(1 + πœ…)2(π‘Ÿπ‘₯2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑦)

2+ π‘Ÿπ‘₯

2)

= 21

1 + πœ…(𝑅𝑦 βˆ’

π‘Ÿπ‘₯1 + πœ…

)βˆšπ‘Ÿπ‘₯2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑦)

2

π‘Žπ‘–2π‘‘π‘–βˆ’1,π‘₯

2 + π‘Žπ‘–2π‘‘π‘–βˆ’1,𝑧

2 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘₯π‘‘π‘–βˆ’1,π‘₯ + 2π‘Žπ‘–(π‘Ÿπ‘–βˆ’1,𝑧 βˆ’ 𝑅𝑦)π‘‘π‘–βˆ’1,𝑧 + π‘Ÿπ‘–βˆ’1,π‘₯2 + π‘Ÿπ‘–βˆ’1,𝑧

2 βˆ’ 2π‘Ÿπ‘–βˆ’1,𝑧𝑅𝑦 + 𝑅𝑦2 βˆ’ 𝑅𝑦

2

+ 2𝑅𝑦1

1 + πœ…π‘Ÿπ‘₯ βˆ’

1

(1 + πœ…)2(2π‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦2 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦 + π‘Žπ‘–

2π‘‘π‘–βˆ’1,𝑦2 ))

= 21

1 + πœ…(𝑅𝑦 βˆ’

π‘Ÿπ‘₯1 + πœ…

)βˆšπ‘Ÿπ‘₯2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦 + π‘Žπ‘–

2π‘‘π‘–βˆ’1,𝑦2 )

Page 9: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 9

π‘Žπ‘–2π‘‘π‘–βˆ’1,π‘₯

2 + π‘Žπ‘–2π‘‘π‘–βˆ’1,𝑧

2 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘₯π‘‘π‘–βˆ’1,π‘₯ + 2π‘Žπ‘–(π‘Ÿπ‘–βˆ’1,𝑧 βˆ’ 𝑅𝑦)π‘‘π‘–βˆ’1,𝑧 + π‘Ÿπ‘–βˆ’1,π‘₯2 + π‘Ÿπ‘–βˆ’1,𝑧

2 βˆ’ 2π‘Ÿπ‘–βˆ’1,𝑧𝑅𝑦 + 2𝑅𝑦1

1 + πœ…π‘Ÿπ‘₯

βˆ’2π‘Ÿπ‘₯

2

(1 + πœ…)2+π‘Ÿπ‘–βˆ’1,𝑦2

(1 + πœ…)+ 2π‘Žπ‘–

π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦(1 + πœ…)

+ π‘Žπ‘–2π‘‘π‘–βˆ’1,𝑦2

(1 + πœ…)

= 21

1 + πœ…(𝑅𝑦 βˆ’

π‘Ÿπ‘₯1 + πœ…

)βˆšπ‘Ÿπ‘₯2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦 + π‘Žπ‘–

2π‘‘π‘–βˆ’1,𝑦2 )

π‘Žπ‘–2π‘‘π‘–βˆ’1,π‘₯

2 + π‘Žπ‘–2π‘‘π‘–βˆ’1,𝑦2

(1 + πœ…)+ π‘Žπ‘–

2π‘‘π‘–βˆ’1,𝑧2 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘₯π‘‘π‘–βˆ’1,π‘₯ + 2π‘Žπ‘–

π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦(1 + πœ…)

+ 2π‘Žπ‘–(π‘Ÿπ‘–βˆ’1,𝑧 βˆ’ 𝑅𝑦)π‘‘π‘–βˆ’1,𝑧 + π‘Ÿπ‘–βˆ’1,π‘₯2 +

π‘Ÿπ‘–βˆ’1,𝑦2

(1 + πœ…)

+ π‘Ÿπ‘–βˆ’1,𝑧2 βˆ’ 2π‘Ÿπ‘–βˆ’1,𝑧𝑅𝑦 + 2𝑅𝑦

1

1 + πœ…π‘Ÿπ‘₯ βˆ’

2π‘Ÿπ‘₯2

(1 + πœ…)2

= 21

1 + πœ…(𝑅𝑦 βˆ’

π‘Ÿπ‘₯1 + πœ…

)βˆšπ‘Ÿπ‘₯2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦 + π‘Žπ‘–

2π‘‘π‘–βˆ’1,𝑦2 )

π‘Žπ‘–2(1 + πœ…)

2 (π‘‘π‘–βˆ’1,π‘₯

2 +π‘‘π‘–βˆ’1,𝑦2

(1 + πœ…)+ π‘‘π‘–βˆ’1,𝑧

2 ) + π‘Žπ‘–(1 + πœ…) (π‘Ÿπ‘–βˆ’1,π‘₯π‘‘π‘–βˆ’1,π‘₯ +π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦(1 + πœ…)

+ (π‘Ÿπ‘–βˆ’1,𝑧 βˆ’ 𝑅𝑦)π‘‘π‘–βˆ’1,𝑧)

+(1 + πœ…)

2(π‘Ÿπ‘–βˆ’1,π‘₯

2 +π‘Ÿπ‘–βˆ’1,𝑦2

(1 + πœ…)+ π‘Ÿπ‘–βˆ’1,𝑧

2 ) βˆ’ (1 + πœ…) (π‘Ÿπ‘–βˆ’1,𝑧𝑅𝑦 + π‘…π‘¦π‘Ÿπ‘₯

1 + πœ…βˆ’

π‘Ÿπ‘₯2

(1 + πœ…)2)

= (𝑅𝑦 βˆ’π‘Ÿπ‘₯

1 + πœ…)βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦 + π‘Žπ‘–2π‘‘π‘–βˆ’1,𝑦

2 )

with πœ‰ = (𝑅𝑦 βˆ’π‘Ÿπ‘₯

1+πœ…)βˆ’1

it follows

π‘Žπ‘–2(1 + πœ…)πœ‰

2(π‘‘π‘–βˆ’1,π‘₯

2 +π‘‘π‘–βˆ’1,𝑦2

(1 + πœ…)+ π‘‘π‘–βˆ’1,𝑧

2 ) + π‘Žπ‘–(1 + πœ…)πœ‰ (π‘Ÿπ‘–βˆ’1,π‘₯π‘‘π‘–βˆ’1,π‘₯ +π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦(1 + πœ…)

+ (π‘Ÿπ‘–βˆ’1,𝑧 βˆ’ 𝑅𝑦)π‘‘π‘–βˆ’1,𝑧)

+(1 + πœ…)πœ‰

2(π‘Ÿπ‘–βˆ’1,π‘₯

2 +π‘Ÿπ‘–βˆ’1,𝑦2

(1 + πœ…)+ π‘Ÿπ‘–βˆ’1,𝑧

2 ) βˆ’ (1 + πœ…)πœ‰ (π‘Ÿπ‘–βˆ’1,𝑧𝑅𝑦 + π‘…π‘¦π‘Ÿπ‘₯

1 + πœ…βˆ’

π‘Ÿπ‘₯2

(1 + πœ…)2)

= βˆšπ‘Ÿπ‘₯2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦 + π‘Žπ‘–

2π‘‘π‘–βˆ’1,𝑦2 )

[π‘Žπ‘–2(1 + πœ…)πœ‰

2(π‘‘π‘–βˆ’1,π‘₯

2 +π‘‘π‘–βˆ’1,𝑦2

(1 + πœ…)+ π‘‘π‘–βˆ’1,𝑧

2 ) + π‘Žπ‘–(1 + πœ…)πœ‰ (π‘Ÿπ‘–βˆ’1,π‘₯π‘‘π‘–βˆ’1,π‘₯ +π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦(1 + πœ…)

+ (π‘Ÿπ‘–βˆ’1,𝑧 βˆ’ 𝑅𝑦)π‘‘π‘–βˆ’1,𝑧)

+(1 + πœ…)πœ‰

2(π‘Ÿπ‘–βˆ’1,π‘₯

2 +π‘Ÿπ‘–βˆ’1,𝑦2

(1 + πœ…)+ π‘Ÿπ‘–βˆ’1,𝑧

2 ) βˆ’ (1 + πœ…)πœ‰ (π‘Ÿπ‘–βˆ’1,𝑧𝑅𝑦 + π‘…π‘¦π‘Ÿπ‘₯

1 + πœ…βˆ’

π‘Ÿπ‘₯2

(1 + πœ…)2)]

2

= π‘Ÿπ‘₯2 βˆ’ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦 + π‘Žπ‘–

2π‘‘π‘–βˆ’1,𝑦2 )

…

βž” This leads to a cubic equation, where the solution can be computed by appropriate algorithms, see

also the Attachement. However, it is probably simpler to compute the Ray-ConicTorus intersetions

with an iterative zero searching algorithm, e.g. the Newton-Raphson Approach.

Page 10: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 10

Special Case: Cylinder Lens The toroidal surface according to equations (2) and (3) can also be used to describe a cylinder surface with

the long axis in the direction of π‘₯. Therefore, the radius of rotation must tend to infinity, 𝑅𝑦 β†’ ∞,. As an

alternative, once can set

π‘₯ = 0 and 𝑅𝑦 = 0,

which leads to

𝑧 = βˆ’sign(π‘Ÿπ‘₯)1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ sign(π‘Ÿπ‘₯)π‘Ÿπ‘₯) .

For the normal unity vector, it yields πœ•π‘‰

πœ•π‘₯= 0 = 𝑧π‘₯ ,

πœ•π‘‰

πœ•π‘¦= sign(π‘Ÿπ‘₯)

𝑦

βˆšπ‘Ÿπ‘₯2 βˆ’ (1 + πœ…)𝑦2

= 𝑧𝑦.

Cylinder-Line Intersection

𝑧 = βˆ’sign(π‘Ÿπ‘₯)1

1 + πœ…(βˆšπ‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2 βˆ’ sign(π‘Ÿπ‘₯)π‘Ÿπ‘₯)

βˆ’sign(π‘Ÿπ‘₯)(1 + πœ…)𝑧 = βˆšπ‘Ÿπ‘₯2 βˆ’ (1 + πœ…)𝑦2 βˆ’ sign(π‘Ÿπ‘₯)π‘Ÿπ‘₯

For π‘Ÿπ‘₯ > 0 and if the 𝑦-values are within the range of equation (8), it results

βˆ’(1 + πœ…)𝑧 = βˆšπ‘Ÿπ‘₯2 βˆ’ (1 + πœ…)𝑦2 βˆ’ π‘Ÿπ‘₯

(π‘Ÿπ‘₯ βˆ’ (1 + πœ…)𝑧)2 = π‘Ÿπ‘₯

2 βˆ’ (1 + πœ…)𝑦2

π‘Ÿπ‘₯2 βˆ’ 2(1 + πœ…)𝑧 π‘Ÿπ‘₯ + (1 + πœ…)

2𝑧2 = π‘Ÿπ‘₯2 βˆ’ (1 + πœ…)𝑦2

(1 + πœ…)2𝑧2 + (1 + πœ…)𝑦2 βˆ’ 2(1 + πœ…)𝑧 π‘Ÿπ‘₯ = 0

(1 + πœ…)2(π‘Ÿπ‘–βˆ’1,𝑧 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑧)2+ (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑦)

2βˆ’ 2(1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑧 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑧) π‘Ÿπ‘₯ = 0

(1 + πœ…)2(π‘Ÿπ‘–βˆ’1,𝑧2 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘§π‘‘π‘–βˆ’1,𝑧 + π‘Žπ‘–

2π‘‘π‘–βˆ’1,𝑧2 ) + (1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑦

2 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦 + π‘Žπ‘–2π‘‘π‘–βˆ’1,𝑦

2 )

βˆ’ 2(1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑧 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑧) π‘Ÿπ‘₯ = 0

(1 + πœ…)(π‘Ÿπ‘–βˆ’1,𝑧2 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘§π‘‘π‘–βˆ’1,𝑧 + π‘Žπ‘–

2π‘‘π‘–βˆ’1,𝑧2 ) + (π‘Ÿπ‘–βˆ’1,𝑦

2 + 2π‘Žπ‘–π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦 + π‘Žπ‘–2π‘‘π‘–βˆ’1,𝑦

2 ) βˆ’ 2(π‘Ÿπ‘–βˆ’1,𝑧 + π‘Žπ‘–π‘‘π‘–βˆ’1,𝑧) π‘Ÿπ‘₯ = 0

π‘Žπ‘–2 ((1 + πœ…)π‘‘π‘–βˆ’1,𝑧

2 + π‘‘π‘–βˆ’1,𝑦2 ) + 2π‘Žπ‘– ((1 + πœ…)π‘Ÿπ‘–βˆ’1,π‘§π‘‘π‘–βˆ’1,𝑧 + π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦 βˆ’ π‘Ÿπ‘₯π‘‘π‘–βˆ’1,𝑧) + (1 + πœ…)π‘Ÿπ‘–βˆ’1,𝑧

2 + π‘Ÿπ‘–βˆ’1,𝑦2

βˆ’ 2π‘Ÿπ‘₯π‘Ÿπ‘–βˆ’1,𝑧 = 0

β‡’ The solution of this quadratic equation

π»π‘Žπ‘–2 + 2πΉπ‘Žπ‘– βˆ’ 𝐺 = 0

where

𝐻 = (1 + πœ…)π‘‘π‘–βˆ’1,𝑧2 + π‘‘π‘–βˆ’1,𝑦

2

𝐹 = (1 + πœ…)π‘Ÿπ‘–βˆ’1,π‘§π‘‘π‘–βˆ’1,𝑧 + π‘Ÿπ‘–βˆ’1,π‘¦π‘‘π‘–βˆ’1,𝑦 βˆ’ π‘Ÿπ‘₯π‘‘π‘–βˆ’1,𝑧

𝐺 = βˆ’(1 + πœ…)π‘Ÿπ‘–βˆ’1,𝑧2 βˆ’ π‘Ÿπ‘–βˆ’1,𝑦

2 + 2π‘Ÿπ‘₯π‘Ÿπ‘–βˆ’1,𝑧

is known as

Page 11: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 11

β‡’ π‘Žπ‘–,1,2 = βˆ’πΉ

𝐻± √

𝐹2

𝐻2βˆ’πΊ

𝐻=

(±√𝐹2

𝐻2βˆ’πΊπ»βˆ’πΉπ»)(±√

𝐹2

𝐻2βˆ’πΊπ»+𝐹𝐻)

(±√𝐹2

𝐻2βˆ’πΊπ»+𝐹𝐻)

=𝐺

𝐹 ± √𝐹2 + 𝐻𝐺 .

In detail it yields

β‡’ π‘Žπ‘– =𝐺

𝐹 βˆ’ √𝐹2 +𝐻𝐺 , for π‘Ÿπ‘₯ > 0

β‡’ π‘Žπ‘– =𝐺

𝐹 + √𝐹2 +𝐻𝐺 , for π‘Ÿπ‘₯ < 0

Page 12: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 12

Parametrical Toroidal Surface Description A torus can be defined parametrically by

[π‘₯𝑦𝑧] = [

(𝑅𝑦 βˆ’ π‘Ÿπ‘₯ + π‘Ÿπ‘₯ cos πœƒ) cosπœ™

π‘Ÿπ‘₯ sin πœƒ

(𝑅𝑦 βˆ’ π‘Ÿπ‘₯ + π‘Ÿπ‘₯ cos πœƒ) sinπœ™

]

In case of πœ… β‰  0 it is proposed to use the implicit description for the 𝑧-term.

[π‘₯𝑦𝑧] =

[ (𝑅𝑦 βˆ’ π‘Ÿπ‘₯ + π‘Ÿπ‘₯ cos πœƒ) cosπœ™

1

√1 + πœ…π‘Ÿπ‘₯ sin πœƒ

𝑧corr ]

Practical Example with MATLAB

A related MATLAB implementation can be found here:

https://de.mathworks.com/matlabcentral/answers/95230-how-do-i-plot-a-toroid-in-matlab

Page 13: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 13

Attachement The following screenshots help to understand the tori equations, which are from [Reithmann2009]4.

Page 12

4 [Reithmann2009] Reithmann, T.: Topologically correct Intersection Curves of Tori and Natural Quadrics, Dissertation

der Johannes Gutenberg-UniversitΓ€t, FB 08: Physik, Mathematik und Informatik, 2009. (See also https://d-

nb.info/995451133/34)

Page 14: Technical Notes for the Raytracing of Toroidal Surfaces

Johannes StΓΆrkle, 2020-03-18 14

Page 69