directory name changed
This commit is contained in:
42
3d_renderer/transformations.py
Normal file
42
3d_renderer/transformations.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import math
|
||||
import numpy as np
|
||||
|
||||
def translate(x, y, z):
|
||||
return np.array([
|
||||
[1, 0, 0, 0],
|
||||
[0, 1, 0, 0],
|
||||
[0, 0, 1, 0],
|
||||
[x, y, z, 1]
|
||||
])
|
||||
|
||||
def rotate_x(a):
|
||||
return np.array([
|
||||
[1, 0, 0, 0],
|
||||
[0, math.cos(a), math.sin(a), 0],
|
||||
[0, -math.sin(a), math.cos(a), 0],
|
||||
[0, 0, 0, 1]
|
||||
])
|
||||
|
||||
def rotate_y(a):
|
||||
return np.array([
|
||||
[math.cos(a), 0, -math.sin(a), 0],
|
||||
[0, 1, 0, 0],
|
||||
[math.sin(a), 0, math.cos(a), 0],
|
||||
[0, 0, 0, 1]
|
||||
])
|
||||
|
||||
def rotate_z(a):
|
||||
return np.array([
|
||||
[math.cos(a), math.sin(a), 0, 0],
|
||||
[-math.sin(a), math.cos(a), 0, 0],
|
||||
[0, 0, 1, 0],
|
||||
[0, 0, 0, 1]
|
||||
])
|
||||
|
||||
def scale(n):
|
||||
return np.array([
|
||||
[n, 0, 0, 0],
|
||||
[0, n, 0, 0],
|
||||
[0, 0, n, 0],
|
||||
[0, 0, 0, 1]
|
||||
])
|
||||
Reference in New Issue
Block a user