Mag function

Magnitude and angle of a vector

Magnitude and angle of a vector

Computes the magnitude of a vector of any dimension. Or angle (in degrees) in 2 dimensions.

Mag(...) Angle(x, y)

Arguments

  • ...: numeric vectors of coordinates or list of coordinates
  • x, y,: x and y directions of the vector

Returns

Mag: A numeric vector the same length as each element of ... that is (x2+y2+...)\sqrt(x^2 + y^2 + ...). Angle: A numeric vector of the same length as x and y that is atan2(y, x)*180/pi.

Details

Helpful to save keystrokes and gain readability when computing wind (or any other vector quantity) magnitude.

Examples

Mag(10, 10) Angle(10, 10) Mag(10, 10, 10, 10) Mag(list(10, 10, 10, 10)) # There's no vector recicling! ## Not run: Mag(1, 1:2) ## End(Not run)

See Also

Other utilities: Anomaly(), JumpBy(), Percentile(), logic

Other utilities: Anomaly(), JumpBy(), Percentile(), logic

  • Maintainer: Elio Campitelli
  • License: GPL-3
  • Last published: 2025-02-24