v1 <- c(-1, 2)
plot(v1[1], v1[2], xlim =c(-2,2), ylim = c(-2,2))
abline(h = 0)
abline(v = 0)

Get angle:

source("vecangle.R")
v1 <- c(-1, 1)
r1 <- sqrt((v1[1] ^ 2) + (v1[2] ^ 2) )

theta1 <- acos(v1[1]/r1)
theta1
theta2 <- asin(v1[2]/r1)
theta2

theta <-vecAngle(v1)
theta
plot(v1[1], v1[2], xlim =c(-2,2), ylim = c(-2,2))
abline(h = 0)
abline(v = 0)
points(r1 * cos(theta), r1 * sin(theta), col = "blue", pch = "+")
newv <- vecRotate(v1, pi/2, v0 =  c(0, 0))

points(newv$v2[1], newv$v2[2], col = "red")
newv


weitingwlin/vennchart documentation built on May 4, 2019, 4:18 a.m.