-
Notifications
You must be signed in to change notification settings - Fork 0
/
rotation.clj
55 lines (47 loc) · 1.46 KB
/
rotation.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(ns geo-yoots.sphere.rotation
(:require [clojure.pprint :as pp]
[geo-yoots.constants :as geo.consts]
[geo-yoots.util.core :as geo.util]
[geo-yoots.sphere.util :as geo.sphere.util]
[clojure.core.matrix :as mtx]
[clojure.core.matrix.stats :as mtx.stats]
[clojure.core.matrix.operators :as mtx.op]))
(mtx/set-current-implementation :vectorz)
(def xyv (mtx/matrix [0 0 1]))
(def xzv (mtx/matrix [0 1 0]))
(def yzv (mtx/matrix [1 0 0]))
#_(defn theta
"Find angle of rotation from normal vector and plane vector"
[normv rotv]
(Math/acos (mtx.stats/cosine-similarity normv rotv)))
(defn theta
"Find angle of rotation from normal vector and plane vector"
[normv rotv]
(Math/acos (mtx.stats/cosine-similarity normv rotv)))
(defn xy-plane-rotation
[normv]
(let [_t (theta normv xyv)
cos-t (Math/cos _t)
sin-t (Math/sin _t)]
(mtx/matrix
[[cos-t sin-t 0]
[(* -1 sin-t) cos-t 0]
[0 0 1]])))
(defn xz-plane-rotation
[normv]
(let [_t (theta normv xzv)
cos-t (Math/cos _t)
sin-t (Math/sin _t)]
(mtx/matrix
[[cos-t 0 sin-t]
[0 1 0]
[(* -1 sin-t) 0 cos-t]])))
(defn yz-plane-rotation
[normv]
(let [_t (theta normv yzv)
cos-t (Math/cos _t)
sin-t (Math/sin _t)]
(mtx/matrix
[[1 0 0]
[0 cos-t sin-t]
[0 (* -1 sin-t) cos-t]])))