forked from dyf/blenderspin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xform.py
40 lines (32 loc) · 1014 Bytes
/
xform.py
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
import numpy as np
def scale3(x,y,z):
return np.array([[x, 0, 0, 0],
[0, y, 0, 0],
[0, 0, z, 0],
[0, 0, 0, 1]])
def translate3(x,y,z):
return np.array([[1, 0, 0, x],
[0, 1, 0, y],
[0, 0, 1, z],
[0, 0, 0, 1]])
def rotate3x(rads):
cth = np.cos(rads)
sth = np.sin(rads)
return np.array([[ 1, 0, 0, 0],
[ 0, cth, sth, 0],
[ 0, -sth, cth, 0],
[ 0, 0, 0, 1 ]])
def rotate3y(rads):
cth = np.cos(rads)
sth = np.sin(rads)
return np.array([[ cth, 0, sth, 0],
[ 0, 1, 0, 0],
[ -sth, 0, cth, 0],
[ 0, 0, 0, 1 ]])
def rotate3z(rads):
cth = np.cos(rads)
sth = np.sin(rads)
return np.array([[ cth, sth, 0, 0],
[ -sth, cth, 0, 0],
[ 0, 0, 1, 0],
[ 0, 0, 0, 1 ]])