-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3d_sphere_v.0.0.lua
65 lines (53 loc) · 1.51 KB
/
3d_sphere_v.0.0.lua
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
56
57
58
59
60
61
62
63
64
65
-- 3d sphere v.0.0
-- produces gradients mapped to the x, y and z axis
-- y rotation, x tilt, z roll
function prepare()
-- tilt & rotation precalc
--[[
x =x × cos(ß) - y × sin(ß)
y= y × cos(ß) + x × sin(ß)
]]--
radius = get_slider_input(RADIUS)
rotation = math.rad(get_angle_input(ROTATION)) -- y-axis = yaw
cosa_a = math.cos(rotation)
sina_a = math.sin(rotation)
tilt = math.rad(get_angle_input(TILT)) -- x-axis = pitch
cosa_t = math.cos(tilt)
sina_t = math.sin(tilt)
roll = math.rad(get_angle_input(ROLL)) -- z-axis = roll
sina_r = math.sin(roll)
cosa_r = math.cos(roll)
end;
function get_sample(x, y)
local r,g,b,a = 1,1,1,1
-- image generation
local px = (x*2.0) - 1.0
local py = (y*2.0) - 1.0
px = px/radius
py = py/radius
local len = math.sqrt((px*px)+(py*py))
if len > 1.0 then return 0,0,0,0 end
local pz = -math.sqrt(1.0 - ((px*px)+(py*py)))
-- roll : changes in x and y
local tx = (cosa_r * px) - (sina_r * py)
local ty = (sina_r * px) + (cosa_r * py)
px = tx
py = ty
-- tilt : changes in y and z
local tz = (cosa_t * pz) - (sina_t * py)
local ty = (sina_t * pz) + (cosa_t * py)
pz = tz
py = ty
-- rotation : changes in x and z
local tx = (cosa_a * px) - (sina_a * pz)
local tz = (sina_a * px) + (cosa_a * pz)
px = tx
pz = tz
px = get_sample_curve(x,y,px/2+.5,PROFILE)
py = get_sample_curve(x,y,py/2+.5,PROFILE)
pz = get_sample_curve(x,y,pz/2+.5,PROFILE)
-- input image
r, g, b, a = get_sample_map(x, y, SOURCE)
return px,py,pz,a
-- return r, g, b, a
end;