calc_spherical_distance: Calculate spherical distance

View source: R/calc_spherical_distance.R

calc_spherical_distanceR Documentation

Calculate spherical distance

Description

Computes the angular distance, in radians, between directions defined by zenith and azimuth angles on the unit sphere.

Usage

calc_spherical_distance(z1, a1, z2, a2)

Arguments

z1

numeric vector. Zenithal angle in radians.

a1

numeric vector. Azimuthal angle in radians.

z2

numeric vector of length one. Zenithal angle in radians.

a2

numeric vector of length one. Azimuthal angle in radians.

Details

This function calculates the angle between two directions originating from the center of a unit sphere, using spherical trigonometry. The result is commonly referred to as spherical distance or angular distance. These terms are interchangeable when the sphere has radius one, as is standard in many applications, including celestial coordinate systems and, by extension, canopy hemispherical photography.

Spherical distance corresponds to the arc length of the shortest path between two points on the surface of a sphere. When the radius is one, this arc length equals the angle itself, expressed in radians.

Value

Numeric vector of the same length as z1 and a1, containing the spherical distance (in radians) from each (z1, a1) point to the reference direction (z2, a2).

Examples

set.seed(1)
z1 <- rnorm(10, 45, 20) * pi/180
a1 <- rnorm(10, 180, 90) * pi/180
calc_spherical_distance(z1, a1, 0, 0)

rcaiman documentation built on Sept. 9, 2025, 5:42 p.m.