mean_angle: Calculate the mean angle

mean_angleR Documentation

Calculate the mean angle

Description

Calculate the mean angle

Usage

mean_angle(x, w = NULL, do_plot = FALSE, lens = -5, ...)

Arguments

x

numeric vector of angles in degrees

w

numeric vector representing weights

do_plot

logical indicating whether to create a visual summary plot

lens

numeric value passed to jamba::warpAroundZero() to adjust the radius

...

additional arguments are ignored

Details

This function takes a vector of angles in degrees (0 to 360 degrees) and returns the mean angle based upon the average of unit vectors.

The function also optionally accomodates weighted mean values, if a vector of weights is supplied as w.

Part of the intent of this function is to be used for color blending methods, for example taking the average color hue from a vector of colors. For this purpose, some colors may have varying color saturation and transparency, which are mapped here as weight w. Colors which are fully transparent should therefore have weight w=0 so they do not contribute to the resulting average color hue. Also during color blending operations, the resulting color saturation is adjusted using the lens argument, the default lens=-5 has a tendency to increase intermediate color saturation.

Value

numeric vector that contains

  • degree the mean angle in degrees

  • radius the actual radius based upon mean unit vectors

  • radius2 the adjusted radius using jamba::warpAroundZero()

See Also

Other colorjam hue warp: add_colorjam_preset(), add_colorjam_step(), adjust_hue_warp(), approx_degrees(), colorjam_presets(), colorjam_steps(), display_degrees(), h2hw(), h2hwOptions(), hcl_to_hsl_hue(), hsl_to_hcl_hue(), hw2h(), plot_colorjam_preset(), remap_colorjam_preset(), validate_colorjam_preset()

Examples

mean_angle(c(120, 45), do_plot=TRUE);


jmw86069/colorjam documentation built on Dec. 16, 2024, 8:02 a.m.