fortplot_polar Module

Polar coordinate transformation and utilities

Provides coordinate transforms between polar (theta, r) and Cartesian (x, y) and utilities for polar plot rendering including angular tick generation.



Variables

Type Visibility Attributes Name Initial
real(kind=wp), public, parameter :: PI = 3.14159265358979323846_wp
real(kind=wp), public, parameter :: TWO_PI = 6.28318530717958647693_wp
real(kind=wp), public, parameter :: DEG_TO_RAD = PI/180.0_wp
real(kind=wp), public, parameter :: RAD_TO_DEG = 180.0_wp/PI

Functions

public pure function normalize_angle(theta) result(normalized)

Normalize angle to [0, 2*pi) range

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: theta

Return Value real(kind=wp)

public pure function format_angle_label(degrees) result(label)

Format angle in degrees as a label string

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: degrees

Return Value character(len=8)


Subroutines

public pure subroutine polar_to_cartesian(theta, r, x, y, theta_offset, clockwise)

Convert single polar coordinate to Cartesian theta: angle in radians r: radius theta_offset: angular offset (default: pi/2 = 90 deg, 0 at top) clockwise: if true, angles increase clockwise

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: theta
real(kind=wp), intent(in) :: r
real(kind=wp), intent(out) :: x
real(kind=wp), intent(out) :: y
real(kind=wp), intent(in), optional :: theta_offset
logical, intent(in), optional :: clockwise

public pure subroutine polar_to_cartesian_arrays(theta, r, x, y, theta_offset, clockwise)

Convert arrays of polar coordinates to Cartesian

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: theta(:)
real(kind=wp), intent(in) :: r(:)
real(kind=wp), intent(out) :: x(:)
real(kind=wp), intent(out) :: y(:)
real(kind=wp), intent(in), optional :: theta_offset
logical, intent(in), optional :: clockwise

public pure subroutine cartesian_to_polar(x, y, theta, r)

Convert Cartesian to polar coordinates Returns theta in [0, 2*pi) range

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x
real(kind=wp), intent(in) :: y
real(kind=wp), intent(out) :: theta
real(kind=wp), intent(out) :: r

public pure subroutine compute_angular_ticks(n_ticks, tick_angles, tick_labels)

Compute angular tick positions and labels for polar plot Returns angles in radians and labels in degrees

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n_ticks
real(kind=wp), intent(out) :: tick_angles(:)
character(len=*), intent(out) :: tick_labels(:)

public pure subroutine compute_radial_ticks(r_min, r_max, n_ticks, tick_values)

Compute radial tick positions for polar plot

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: r_min
real(kind=wp), intent(in) :: r_max
integer, intent(in) :: n_ticks
real(kind=wp), intent(out) :: tick_values(:)