Guest User

Untitled

a guest
Dec 13th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. outer_product <- function (a, b) {
  2. c(a[2]*b[3] - a[3]*b[2], a[3]*b[1] - a[1]*b[3], a[1]*b[2] - a[2]*b[1])
  3. }
  4.  
  5. d <- function(t) {
  6. s <- t/sqrt(3)
  7. h <- sqrt(1 - ((1 + sqrt(3)/2)^2 + (1/2)^2)*s^2)
  8.  
  9. A <- c(s, 0, 0)
  10. B <- c(-1/2*s, sqrt(3)/2*s, 0)
  11. A_ <- c(-sqrt(3)/2*s, 1/2*s, h)
  12. B_ <- c(0, -s, h)
  13.  
  14. AA_ <- A_ - A
  15. BB_ <- B_ - B
  16. BA <- A - B
  17.  
  18. AA_xBB_ <- outer_product(AA_, BB_)
  19. ((A - B) %*% AA_xBB_) / sqrt(AA_xBB_ %*% AA_xBB_)
  20. }
  21.  
  22. ts <- (1:89)/100
  23. ds <- c()
  24. for (i in 1:89) {
  25. ds[i] <- d(ts[i])
  26. }
  27. plot(ts, ds, type="l")
Add Comment
Please, Sign In to add comment