# bang: Angle between two 2D normalized vectors In RFOC: Graphics for Spherical Distributions and Earthquake Focal Mechanisms

## Description

Calculates the angle between two 2D normalized vectors using dot and cross product

## Usage

 `1` ```bang(x1, y1, x2, y2) ```

## Arguments

 `x1` x coordinate of first normalized vector `y1` y coordinate of first normalized vector `x2` x coordinate of second normalized vector `y2` y coordinate of second normalized vector

## Details

The sign of angle is determined by the sign of the cross product of the two vectors.

angle in radians

## Note

Vectors must be normalized prior to calling this routine. Used mainly for vectors on the unit sphere.

## Author(s)

Jonathan M. Lees <jonathan.lees@unc.edu>

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```v1 = c(5,3) v2 = c(6,1) a1 = c(5,3)/sqrt(v1^2+v1^2) a2 = c(6,1)/sqrt(v2^2+v2^2) plot(c(0, v1,v2 ) , c(0, v1,v2), type='n', xlab="x", ylab="y" ) text(c(v1,v2) , c(v1,v2), labels=c("v1", "v2"), pos=3, xpd=TRUE) arrows(0, 0, c(v1,v2 ), c(v1,v2)) B = 180*bang(a1, a1, a2, a2)/pi title(paste(sep=" ", "Angle from V1 to V2=",format(B, digits=2)) ) ```

RFOC documentation built on May 2, 2019, 1:38 p.m.