This repository has been archived by the owner on Apr 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use Signal instead of Input. See JuliaGizmos/Reactive.jl#65
- Loading branch information
1 parent
18d281a
commit bbbab0c
Showing
31 changed files
with
154 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,48 @@ | ||
meshgrid(v::AbstractVector) = meshgrid(v, v) | ||
|
||
function meshgrid{T}(vx::AbstractVector{T}, vy::AbstractVector{T}) | ||
m, n = length(vy), length(vx) | ||
vx = reshape(vx, 1, n) | ||
vy = reshape(vy, m, 1) | ||
(repmat(vx, m, 1), repmat(vy, 1, n)) | ||
end | ||
|
||
function meshgrid{T}(vx::AbstractVector{T}, vy::AbstractVector{T}, | ||
vz::AbstractVector{T}) | ||
m, n, o = length(vy), length(vx), length(vz) | ||
vx = reshape(vx, 1, n, 1) | ||
vy = reshape(vy, m, 1, 1) | ||
vz = reshape(vz, 1, 1, o) | ||
om = ones(Int, m) | ||
on = ones(Int, n) | ||
oo = ones(Int, o) | ||
(vx[om, :, oo], vy[:, on, oo], vz[om, on, :]) | ||
end | ||
|
||
# Calculate the Julia set on a grid | ||
x = [Float32(i)*im for i=-1.5:0.5:500] | ||
y = [Float32(i)*im for i=-1:1:500] | ||
x,y = meshgrid(-1.5f0:0.5f0:500f0, -1f0:1f0:500f0) | ||
x *= 1im | ||
y *= 1im | ||
println(size(x)) | ||
println(size(y)) | ||
z = x + 1im * y | ||
|
||
julia = zeros(Float32, size(z)) | ||
const julia = zeros(Float32, size(z)) | ||
|
||
for i=1:50 | ||
z = z^2 - 0.70176 - 0.3842im | ||
julia += 1 / 2f0 + i) * (z * conj(z) > 4) | ||
for i in eachindex(julia) | ||
z[i] = (z[i]^2) - 0.70176 - 0.3842im | ||
x = (z[i] * (real(conj(z[i])) > 4)) | ||
julia[i] += real(1f0 / (2f0 + i) * x) | ||
end | ||
end | ||
|
||
maxval = maximum(julia) | ||
map!(julia ) do val | ||
val / maxval | ||
end | ||
using GLVisualize | ||
w,r =glscreen() | ||
# Display it | ||
view(visualize(julia)) | ||
|
||
# A view into the "Canyon" | ||
view(65, 27, 322, [30., -13.7, 136]) | ||
show() | ||
|
||
r() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# As long as we don't calculate bounding boxes on the gpu, this needs to do: | ||
Base.minimum(t::Texture) = minimum(gpu_data(t)) | ||
Base.maximum(t::Texture) = maximum(gpu_data(t)) | ||
|
||
call(::Type{AABB}, a::GPUArray) = AABB{Float32}(gpu_data(a)) | ||
call{T}(::Type{AABB{T}}, a::GPUArray) = AABB{T}(gpu_data(a)) | ||
|
||
call(::Type{AABB}, a::GPUArray) = AABB(gpu_data(a)) | ||
call(::Type{AABB}, a::GPUArray) = AABB(gpu_data(a)) | ||
|
||
|
||
particle_grid_bb{T}(min_xy::Vec{2,T}, max_xy::Vec{2,T}, minmax_z::Vec{2,T}) = AABB{T}(Vec(min_xy..., minmax_z[1]), Vec(max_xy..., minmax_z[2])) | ||
|
||
Base.call{T, T2, T3}(::Type{AABB{T}}, positions::Texture{Point{3, T2}, 1}, scale::Texture{Vec{3, T3}, 1}, primitive_bb) = AABB{T}(gpu_data(positions), gpu_data(scale), primitive_bb) | ||
Base.call{T, T2, T3}(::Type{AABB{T}}, positions::Texture{Point{3, T2}, 1}, scale::Vec{3, T3}, primitive_bb) = AABB{T}(gpu_data(positions), scale, primitive_bb) | ||
|
||
|
||
|
||
function call{T}(Type{AABB{T}}, p::Particles) | ||
primitive_bb = AABB{Float32}(p.primitive) | ||
AABB{T}(p.positions, p.scale, primitive_bb) | ||
end | ||
|
||
|
||
|
||
|
||
function call{T, T2, T3, N}(::Type{AABB{T}}, positions::Vector{Point{N, T2}}, scale::Vec{N, T3}, primitive_bb) | ||
primitive_scaled_min = minimum(primitive_bb) .* scale | ||
primitive_scaled_max = maximum(primitive_bb) .* scale | ||
pmax = max(primitive_scaled_min, primitive_scaled_max) | ||
pmin = min(primitive_scaled_min, primitive_scaled_max) | ||
main_bb = AABB{T}(positions) | ||
AABB{T}(minimum(main_bb) + pmin, maximum(main_bb) + pmax) | ||
end | ||
function call{T, T2, T3, N}(::Type{AABB{T}}, positions::Vector{Point{N, T2}}, scale::Vector{Vec{N, T3}}, primitive_bb) | ||
_max = Vec{N, T}(typemin(T)) | ||
_min = Vec{N, T}(typemax(T)) | ||
for (p, s) in zip(positions, scale) | ||
p = Vec{N, T}(p) | ||
s_min = Vec{N, T}(s) .* minimum(primitive_bb) | ||
s_max = Vec{N, T}(s) .* maximum(primitive_bb) | ||
s_min_r = min(s_min, s_max) | ||
s_max_r = max(s_min, s_max) | ||
_min = min(_min, p + s_min_r) | ||
_max = max(_max, p + s_max_r) | ||
end | ||
AABB{T}(_min, _max) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.