Guest User

Untitled

a guest
Dec 13th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 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.  
  17. AA_xBB_ <- outer_product(AA_, BB_)
  18. ((A - B) %*% AA_xBB_) / sqrt(AA_xBB_ %*% AA_xBB_)
  19. }
  20.  
  21. ts <- (1:89)/100
  22. ds <- c()
  23. for (i in 1:89) {
  24. ds[i] <- d(ts[i])
  25. }
  26. plot(ts, ds, type="l")
Add Comment
Please, Sign In to add comment