# Refraction Simulation Help

This is the Help Page for Simulation of Atmospheric Refraction. It describes all parameters the user can specify. It is displayed if you click the icon on the right each control element. For a description of the simulation itself see How the Simulation works.

## Use the Arrow Keys to change the Value

The values of most input fields can be changes with the Arrow Keys of the keyboard in multiple step sizes.

Place the cursor in an input field, by clicking on it. Press the Up Arrow key on the keyboard to increase the value. Press the Down Arrow key to decrease the value.

How much the field value is changed depends on the field. You can modify the step size using the Control and Alt keys:

Control+Arrow
increases the step size by a factor of 10
Alt+Arrow
decreases the step size by a factor of 10
Control+Alt+Arrow
decreases the step size by a factor of 100

Press the Esc key to reset the field to the initial value.

## Display

Below the two displays is an associated control panel, called the Display Panel, where you can select one of three Display Types.

### Display Type

Tip: you can hide the right sidebar to enlarge the displays by clicking on the arrow button at the right edge of the page title. You may also want to maximaze the browser window. If you want to make comparisons that are not natively supported by the App, open a second separate browser window.

Each of the two displays may show a different image or graph:

Image
displays a rendered image of a scene composed of Targets using a Ray Tracer which calculates for each pixel of the image the light rays into the scene. With the settings Model and Refraction you can select between the Flat Earth and Globe Model and how the calculated light rays are bent due to Refraction.
Rays
displays a side view of the scene with some light rays. With the settings Model and Refraction you can select between the Flat Earth and Globe Model and how the calculated light rays are bent due to Refraction. Select the panel Graph to change some parameters such as the range that is displayed or how many rays are drawn.
Note: Do not forget to select Refraction = Custom to display refracted light rays!
Baro
Shows 2 of 3 barometric curves at once: Temperature, Temperature Gradient and Refraction as a function of altitude. With the Curve Options Left and Right on the panel below you can select which curves you want to be displayed on the corresponding display part.

Tip: Set Display = Baro if you change the Barometric Settings on the Baro panels to show how this affects the calculated curves.

### Display Model

You can select whether the display shows the Flat Earth or Globe Model simulation. To both models Refraction can be applied independently.

Tip: Check the Camera Options EyeLvl and Horizon on the panel Rendering to display the eye level and/or the line of the geometric horizon of the globe earth.

### Display Refraction

Specifies which Refraction type to apply on the Display Type Image and Rays.

Zero
no Refraction is applied, corresponding to a Refraction Coefficient k = 0. All light rays are straight lines.
Standard
Standard Refraction is applied. The curve of a light ray at a certain point depends on the air pressure, air temperature, the temperature gradient and the vertical angle of the light ray at that point. Pressure, tempertaure and gradient are derived from the altitude at every point on the light ray by using the model of the Standard Atmosphere. From these values is the Refraction Coefficient calculated, which is different for each point along a light ray. So Standard Refraction does not result in a constant bending of the light rays. Each light ray has a slightly different overall bending depending on the path it takes through the simulated Atmosphere.
Custom
The Refraction is calculated from the Barometric Settings on the Baro Observer and Baro Target panels. See How Custom Refraction is derived.

### Display Curve

If the Display Type Baro is selected, you can select which 2 of 3 calculated barometric curves are displayed.

Temp
shows the Temperature as a function of altitude. This curve is directly computed from the Barometric Settings on the Baro Observer and Baro Target panels. The curve is a Spline Interpolation through the specified temperature points.
Grad
shows the Temperature Gradient as a function of altitude. This curve is the Derivative of the Temperature Curve with respect to altitude.
Refr
shows the Refraction Coefficient as a function of altitude. This curve is calculated from the Temperature, the Temperature Gradient and the specified air pressure. See How Custom Refraction is derived.

## Camera

The Camera and the Ray Tracer are part of the Rendering Panel. The Camera defines the visual aspects of the rendered images.

### Camera Observer Height

The Observer Height specifies the altitude of the camera measured from the surface of the earth. It also defines the position of the Eye Level Line, which can be displayed in the rendered images by selecting the corresponding Camera Options.

### Camera Zoom

The Camera Zoom specifies the viewing angle, like on a real camera. The greater the number, the smaller the angle, the more the magnification. The value is calibrated to a 35 mm sensor diagonal size.

Tip: When creating new Targets it is often necessary to change the Zoom temporarily to see the whole Target until its parameters are set.

### Camera Tilt

The Camera Tilt can be used to vertically adjust the image. Positive values tilt the camera up and the image moves down.

### Camera Pixel Size

You can select the final Pixel Size of the rendered images to stop the rendering process at an earlier state. This may be usefull while building a new scene and you quickly want a rough preview of the scene.

### Camera Oversampling

Of no Oversampling is selected, then for each image pixel exactly one point of the scene is sampled using a single light ray. If you select one of the other Oversampling settings, for each image pixel multiple neighboring scene points are sampled and the mean color value is displayed as the pixel color.

Oversampling is useful if some pattern or loaded images have a higher resolution than the display. It may reduce some artefacts and smoothes edges (antialiasing).

Oversampling slows down the rendering process according to the selected rate. 2x2 takes 4 times the rendering time than with no Oversampling.

### Camera Options

Smooth
makes the image looking a bit blurry. It combines neighboring image pixels to a mean value. If Smooth is enabled, at least 4 pixels are sampled for each image pixel. This slows down the rendering time by a factor of 4. This option may be usefull, if the image is pixelated.
EyeLvl
displays a magenta horizontal line in the rendered image indicating where eye level is. Eye level is defined as the horizontal plane at Camera Height perpendicular to the vertical at the camera position.
Horizon
displays a cyan horizontal line where the geometric horizon of the globe earth is located. This line serves as a reference to see how much the real horizon is raised or lowered by Refraction.

Note: On the Display Model Flat Earth the eye level line is identical with the horizon line: "The horizon always raises to eye level" (flat earther claim erroneously, this is what we can observe).

## Ray Tracer

The Ray Tracer is the heart of the simulator. It calculates all light rays from the observer to all the targets in a scene according to the Barometric Settings the user provides. From the intersections of the light rays with the targets the color of each image pixel is calculated.

See How the Simulation works for more details.

### Ray Tracer Horizon

If a light ray does not hit any Target, a horizon color is displayed. The horizon color is a color gradient specified by Horizon Color, Zenith Color and Gradient Height.

Horizon Color
is the color used at zero altitude.
Zenith Color
is the color used above Gradient Height. Between zero altitude and Gradient Height a gradient between the two colors is calculated.
Gradient Height
specifies the upper limit of the color gradient. Above this height the horizon is painted in the Zentith Color.

You can set the Gradient Height to auto by entering anything but a number. If the field is set to auto then the value is calculated such that the top of the image is the limit.

See Color for how a color value is entered.

### Ray Tracer Horizon Dist

Each light ray is divided into a number of Ray Segments, depending on Ray Delta or Num Segments. Each light ray is followed until is hits an opaque target or exceeds the value Horizon Dist.

Tip: To speed up the rendering process set Horizon Dist as small as possible. If a Target lies beyond this distance, it is not displayed, so this value has to be greater than the Target distances.

Tip: Set the value to auto by entering anything except a number into the field. If the field displays auto, then the distance of the farthest upright Target plus some margin is used as the horizon distance.

### Ray Tracer Ray Delta

Each light ray is divided into a number of Ray Segments. Ray Delta specifies the length of each segement. The smaller the value, the slower the rendering process, but the more accurate the simulation.

Because the simulation makes use of curved ray segments, the accuracy of the simulation is not much dependent on the segment length. A value of 1/25 the Horizon Dist is suitable.

If you have many Targets in different distances you have to set a shorter segment length, so that at least 2 to 3 segments are computed between the observer and the first target.

Tip: Set the value to auto by entering anything except a number into the field. If the field is set to auto it displays "Num Segments >>" and the segment length is calculated by (Horizon Dist / Num Segments).

### Ray Tracer Num Segments

Each light ray is divided into a number of Ray Segments. With Num Segments you can specify how much segments have to be used for each light ray until it reaches Horizon Dist.

If this field is disabled and shows "<< Ray Delta", then the segment length is specified by the field Ray Delta instead. You can enable this field by entering anything but a number into the field Ray Delta. See also description there.

### Ray Tracer Max Segments

Each light ray is divided into a number of Ray Segments specified by Ray Delta or Num Segments.

Max Segments limits the number of ray segments to prevent infinite loops in the calculations.

If Max Segments for a light ray is exceeded before hitting a Target or the Horizon, the correponding pixel is displayed in dark red.

Tip: If you want to stop the rendering process before it is finished, simply select another Display Type than Image.

## Ray Tracer Visibility

Simulates haze or fog. A value of 0 means no visibility limit, so you can see until Ray Tracer Horizon Dist. All other values give the distance, where only 50% visibility happens. In double the distance you have 50% of 50% visibility, that is 25%.

## Barometric Settings

There are two panels for Barometric Settings: Baro Observer and Baro Target. The panels are identical but the values are applied to two different distances from the observer.

The values of the Baro Target panel are optional. If no values are providet, the values of the Baro Observer panel are used for the whole scene.

### Baro Pressure

Altough the barometric pressure has not as much influence on Refraction as the Temperature Gradient, it can be specified anyway. You can only spcify one single pressure. The specified pressure is gradually blended into the pressure of the Standard Atmosphere below 11 km. Above this the pressure gradient of the Standard Atmosphere is always applied.

In the field Pressure Alt you can specify at which altitude the pressure in the field Pressure is measured. The altitude is limited to 9 km and the pressure is limited to a realistic range, depending on the altitude provided.

### Baro Measure Dist

The Measure Dist is the distance from the observer, where the barometric data has to be applied. If you specify a second set of barometric data in the Baro Target panel, don't forget to set the distance accordingly.

The distance in the Baro Observer panel is limited to 0 and 1 km less than the value specified in the Baro Target panel.

If you only specify data on the observer panel, this data is applied to the whole scene. If you additionally specify data on the target panel, the values between the two distances are interpolated according to the position of a Ray Segment. Beyond this distances the data of the nearer settings is applied.

## Baro Smoothness

The specified Baro Altitude and Temperature pairs define the Temperture Curve. The simulation connects tge data point with a so called spline curve. With Smoothness can be specified how smooth the curve is at the data points. A value of 0 results in straight lines between the data points. A value of 1 makes the curve as smooth as possible but may result in "overshoothing" of the curve. Default value is 0.75.

### Baro Altitude and Temperature

You can specify 5 pairs of Altitude/Temperature points. The simulator connects these points with a smooth Spline Curve. This curve specifies the Temperature Curve which is the basis for the Refraction calculation.

The entries in the field are automatically sorted by altitude. If you want to insert a new point between two existing ones, simply enter it in a field that is labeled as undefined. To delete a point, enter any value except a number into the Altitude field.

Tip: Select the Display Type Baro below one of the displays to see the calculated curves. The provided data points are marked on the Temperature Curve.

## Graphs

The Graphs panel can be used to specify some display options if one of the Display Types Rays or Baro ist selected. If none of these display types is selected, the controls of the panel are disabled.

### Graphs Alt Range

The Alt Range specifies the top limit of the altitude that is displayed on the Rays and Baro Display Types.

If auto is displayed in the input field, the range is selected automatically according to the highest temperature point provided in the Baro Settings. To set the field to auto enter anything except a number.

Note: The Alt Range value is only applied in the Display Type Rays if Aspect Ratio streched is selected.

### Graphs Dist Range

The Dist Range specifies the distance range of the Rays Display.

If the input field displays auto, the distance of the farthest upright Target is used or if no such Target exists a default value is selected. To set the field to auto enter anything except a number.

### Graphs Ray Angle

The Ray Angle specifies the spreading angle of the light rays on the Rays Display.

Note: if the Aspect Ratio is not set to 1:1, the scale of the vertical axes is magnified a lot. To get a displayed angle of say 45° you have to enter a much smaller value, often much less than 1°.

### Graphs Num of Rays

The Num of Rays specifies the number of light rays shown on the Rays Display.

### Graphs Aspect Ratio

Because the distance of the Targets in almost all cases is much greater than the Observer Height, the Rays Display is scaled very differently in the two axes to make the bending of the light rays visible.

With Aspect Ratio you can change the vertical scaling:

auto
The vertical scaling is set automatically depending on the Observer Height.
streched
The range from the field Alt Range is applied.
1:1
The vertical scale is set so that the display shows a 1:1 aspect ratio. In this view the curvature of the light rays is only visible on very long distances under specific Refraction conditions. This mode exists only to show the real scale of light Refraction of the atmosphere.

### Graphs Ray Spreading

On the Rays Display you can select whether the light ray source is the observer or whether the rays are sent out parallel along the vertical axes.

### Graphs Options

On the Rays Display you can select whether the horizon line and the eye level line are displayed or not. They correspond to the Camera Options with the same label.

The horizon line is the tangent from the observers eye to the surface of the earth. This corresponds to the geometrical horizon displayed in the rendered images.

Note: The location of the geometrical horizon is indicated by a vertical arrow. You can read off the distance to the geometrical horizon on the horizontal scale below.

## Target

A Scene is composed of a list of Targets. A Target can be an Image or a Pattern.

Each Target can be positioned and rotated individually.

A Target can be sized as needed. This is important if you use images that show a certain scene like a skyline.

A Target can have Boundaries/Limits or it can be infinetely extended in any direction. If a Target is an image without boundary limits, the image is repeated.

Targets can be made partially transparent. Simulated Light Rays are sent through the scene until they hit an opaque Target or exceed the Horizon limit.

To create a new Target, open the Targets panel and click on New. A copy of an internal Target Template is created. You can also create a Copy of the current selected Target by clicking Clone and then change some parameters. Or you can create one of the Preset Targets.

Note: Targets are treated differently in the Model Flat Earth and Globe Earth. On the Flat Earth model the targets are always flat planes. On the Globe Model the same targets are wraped around the globe, so targets that are not entirely vertical are curved. This allows to create targets like water images that are flat on the Flat Earth display but curved on the Globe Earth display.

Note: For some scenes the order of the Targets may be important. You can move the Targets in the sequence with the buttons Move Up and Move Down.

### Target Name

Target Name is only for display and has no function.

Tip: Give each Target a descriptive name to quickly identify it when switching between Targets with Prev and Next buttons above.

### Target Position

Each Target has a zero point whose position in the scene can be specified by these parameters.

Images
The Zero Point of Image-Targets is at the bottom center of the image.
Patterns
The Zero Point of Pattern-Targets is at the center of the pattern.

Coordinate System: Dist X points into the display, Up Y points up and Right Z points to the right.

### Target Orientation

You can rotate a Target around the three axes X, Y, Z. If a Target is not rotated it is facing the camera. The Target gets rotated around its Zero Point.

Coordinate System: X axes points into the display, Y axes points up, Z axes points to the right.

To create a Target that lies at the ground, eg. water, you have to rotate the Target around the Z axes −90°.

### Target Width and Height

You have to specify a Width and Height for each Target. Width and Height are in World Coordinates. How big a Target will appear on the display depends on its position and the Camera Focal Length too.

If you set one of the fields to auto, the other value is calculated such that the aspect ratio of the image is maintained. If you set both fields to auto, the native image size or a default size is selected. You set a field to auto by entering anything except a number.

### Target Limits

Each Target like an Image or a Pattern can have boundaries or not. You can specify boundaries on each side of a Target separately.

The Limits of the Target don't have to match with the edges of an Image. Specifying Limits less than the Target Width and Height of an image, you can crop the image. If the Limits exceed the edges of the image, the image gets repeated. You can specify no Limits, in which case the image is repeated in all directions infinitely. This is usefull eg. for water.

When a Target is a Pattern, you probably want the pattern to be repeated a certain times on each side. The Target Width and Height defines the size of the base Pattern without repetition. By extending the Limits/Boundaries you can repeat the base Pattern arbitrarily.

Note: Some Patterns like the Light Pattern are not repeatable. Set the Target Limit Type of such Patterns to Width/Height so that the App does not have to check collisions of the light ray with that Target outside its visible range.

With Limit Type you can specify which type of limit is applied.

Custom
You have to specify the limit of each side of the Target with the Limit fields below.
Width/Height
The Target Width and Height are the limits of the Target.
no Limits
The Target has no boundary and the image or pattern is repeated infinitely.

Note: With the Custom option you can specify a limit for each side respectively. If one side should be limitless, enter anything except a number.

### Target Hide

You can temporarily hide a Target with this option. This way you don't have to delete targets you don't want to see in the rendered image.

Tip: define two water pattern, one opaque and one transparent and quickly swich between them by hiding one of them. You can quickly create the second water pattern with the Clone button.

### Target Image URL

You can load an image from the web into a Target by entering the URL to the image in this field. You have then to specify how big in world coordinates the image should appear by entering the dimensions in the fields Target Width and Height. By default a Target is vertical, but can be rotated with Target Orientation. The boundaries of the image can be defined by Target Limits.

The loading state of the image is displayed on the right of the input field:

ok
the image could be loaded and should be displayed if the Target is in the camera frame and not obstructed.
loading
the image is loading from the server. The image is redrawn as soon as the image is loaded. Until then the target is displayed white.
reloading
the first attempt to load the image from the server failed and the App tries again.
error
the image could not be found or loaded. Check the URL for errors.
failed
the image could be loaded but the server does not grant access to the pixels of the image, so the image can not be displayed. Servers must be configured to grant access to the pixels of hosted images. Wikipedia is configured accordingly.

I can host an image for you if you get in contact with me.

### Target Pattern

Select a Pattern to fill the Target with. Depending on the selected Pattern you have to specify some Parameters. Each Pattern can have a different number of Parameters. The Parameter fields that are not used by a Pattern are disabled.

If a Target Image URL is specified, this option is disabled, because the image has priority. If you want to create a Pattern-Target, the Target Image URL field must be empty.

### Target Alpha

With the Alpha value you can make any Target globaly transparent. A value of 1 means the Traget is opaque. A value of 0 means the Traget is fully transparent and invisible.

Note: you can additionally specify an Alpha value for each Color with the Alpha Channel. The Color Alpha Channel and the Alpha value are combined (multiplied).

You can specify a single Color in an Image or Pattern as transparent with the Transp Color field.

### Target Transparent Color

You can specify an individual color of the Target to be transparent with the Tranp Color field. This way you can for example overlay multiple rotated Patterns by making some color of each Pattern transparent.

If you do not want to use the Transparent Color, enter anything except numbers.

If you have an image specified in the field Target Image URL, you can make a certain color of the image transparent. So for example you can draw an image and use a specific color as the transparent color.

You can specify the Transparency of the whole Target with the Alpha field.

### Target Pattern Parameters

Each Target Pattern has its own set of Parameters to specify its appearance on the display. Not used Parameters are disabled.

## Color

Colors are composed of 3 or 4 values in the range from 0 to 1. The first 3 values give the amount of the base colors red, green and blue (rgb) in this order. This base colors are mixed together accordingly to define the color.

The optional 4th value is the Alpha channel. It specifies the transparency of the color. If you omit this value or set it to 1, the color is opaque. A value of 0 is fully transparent = invisible.

To specify a color you have to enter 1 to 4 values in a Color field. There are 3 ways to enter a color:

1. 3 or 4 values separated by space and each value between 0 and 1. If you specify less than 3 values, the previous value will be copied. So if you enter "1", the input gets expandet to "1 1 1". If you enter "0 1" it is expandet to "0 1 1". If you omit the 4th value (alpha channel), it is set to 1. The alpha channel is only displayed if it is less than 1.
2. 3 or 4 values separated by space and each value between 0 and 255. As soon as at least one entered value is greater than 1 all values are treated as 8 bit numbers with values between 0 and 255. They are then scaled down to 0 to 1 and displayed as such.
3. A hecadecimal code as is often used in graphics applications. The value has to be preceeded by a # or 0x and followed by 6 digits 0..9 and a..f. So the color red can be represented by #ff0000.

## Specialist Terms

### Target

A Scene is composed of a list of Targets. A Target can be an Image or a Pattern.

Each Target can be positioned and rotated individually.

A Target can be sized as needed. This is important if you use images that show a certain scene like a skyline.

A Target can have Boundaries/Limits or it can be infinetely extended in any direction. If a Target is an image without boundary limits, the image is repeated.

Targets can be made partially transparent. Simulated Light Rays are sent through the scene until they hit an opaque Target or exceed the Horizon limit.

To create a new Target, open the Targets panel and click on New. A copy of an internal Target Template is created. You can also create a Copy of the current selected Target by clicking Clone and then change some parameters. Or you can create one of the Preset Targets.

Note: Targets are treated differently in the Model Flat Earth and Globe Earth. On the Flat Earth model the targets are always flat planes. On the Globe Model the same targets are wraped around the globe, so targets that are not entirely vertical are curved. This allows to create targets like water images that are flat on the Flat Earth display but curved on the Globe Earth display.

Note: For some scenes the order of the Targets may be important. You can move the Targets in the sequence with the buttons Move Up and Move Down.

### Horizon

Because each simulated Light Ray is dividet into many Ray Segments, a limit must be defined so that the calculation is stopped if no opaque Target is hit. This limit is called the Horizon.

A color gradient can be specified for the Horizon, so that a light ray hitting the horizon has a defined color assigned to it. The specified Horizon Distance limits how far a light ray has to be calculated.

### Ray Segment

In the simulation each light ray is dividet into many Ray Segments. For each Ray Segment the Ray Curvature is calculated separately from the Refraction Coefficient at the position of the Ray Segment, see How Custom Refraction is derived.

### Ray Curvature

The Ray Curvature is the bending of a simulated Ray Segment. The Ray Curvature is derived from the Refraction Coefficient and the vertical angle of the Ray Segment at its position.

### Refraction Coefficient

The Refraction Coefficient is a measure of the Ray Curvature of a light ray with respect to the radius of the earth. The Refraction Coefficient is defined as:

(1)
where'
 $k$ ' =' 'Refraction Coefficient $R_\mathrm{E}$ ' =' '6371 km = radius of the earth $R_\mathrm{R}$ ' =' 'radius of a light ray segment

A value of k = 0 means the Ray Segment is straight. A value of k = 1 means the Ray Segment has the same curvature radius as the earth. Ray segments with negative Coefficients are bent upwards.

The Refraction Coefficient can be calculated from atmospheric properties such as Pressure, Temperature and Temperature Gradient at any position of a light ray segment. It also depends on the vertical angle of the ray segment, see equation (1).

The Refraction Coefficient in reality is slightly different at each location of a light ray from the observer to the Target. In practical applications like survey a mean Refraction Coefficient may be used as an approximation. The simulation calculates the individual Refraction Coefficient for each Ray Segment along the whole way from the observer to a target.

### Refraction Curve

The Refraction Curve describes the Refraction Coefficient as a function of altitude, so each altitude is a certain Refraction Coefficient assigned. The Refraction Curve is derived from the Barometric Settings, see How Custom Refraction is derived.

The simulation calculates two Refraction Curves, one for the observer location and one for a Target location the user can specify. For all locations between observer and target the Refraction Coefficient is derived by interpolating the Refraction Coefficient from this two curves according to the altitude and location of a Ray Segment. If no Barometric Settings are defined for a target location, the observer Refraction Curve is used everywhere.

### Pressure Curve

The Pressure changes with altitude. Such a change is described by a Pressure Curve, which gives the Pressure as a function of altitude.

The simulation uses the Standard Atmosphere as the basis for the Pressure Curve but modifies it according to the user specified Pressure entered in the Barometric Settings.

### Temperature Curve

The temperature changes with altitude. Such a change is described by a Temperature Curve, which gives the Temperature as a function of altitude.

The simulation uses some discrete user specified temperature values to calculate a smooth Temperature Curve through these points. The calculated curve blends into the curve as defined by the Standard Atmosphere above the highest specified Temperature point.

### Temperature Gradient

The Temperature Gradient describes the change in Temperature at each altitude. Mathematically it is the Derivative of the Temperature Curve with respect to altitude.

The simulation calculates a Temperature Gradient Curve from the Temperature Curve.

### Temperature Gradient Curve

The Temperature Gradient Curve is a mathematically curve that connects all Temperature Gradient values for a specific altitude and is derived from the Temperature Curve. The Temperature Gradient Curve is used in the calculation of the Refraction Curve.

### Standard Atmosphere

The Standard Atmosphere defines curves for Temperature, Pressure, air Density and Temperature Gradient for each altitude up to about 85 km. These curves are derived from mean values and used as a reference in many applications, eg. in aviation.

The simulation contains the Standard Atmosphere model and uses it for regions the user does not provide atmospheric data data.

 About Walter Bislin (wabis) Rights Public Domain
 More Page Infos / Sitemap Created Thursday, November 22, 2018
 Scroll to Top of Page Changed Wednesday, August 28, 2019