Skip to content

Commit

Permalink
crumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
apaoluzzi committed Jun 16, 2019
1 parent 0ff5ddc commit 534f8cd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
@@ -1,9 +1,9 @@
julia 1.0
LinearAlgebra

LinearAlgebraicRepresentation
Triangle
StaticArrays
LinearAlgebra
DataStructures
VoronoiDelaunay
QHull
Expand Down
43 changes: 43 additions & 0 deletions examples/hpc/Convex2d.jl
@@ -0,0 +1,43 @@
using QHull
using Revise
using ViewerGL
GL = ViewerGL
using Plasm, QHull

# ////////////////////////////////////////////////////////////////////////
function GLHull2d(points::Array{Float64,2})

ch = QHull.chull(points)
verts = ch.vertices
vdict = Dict(zip(verts, 1:length(verts)))
edges = [[vdict[u],vdict[v]] for (u,v) in ch.simplices]
points = points[verts,:]

faces = edges
vertices=Vector{Float32}()
normals =Vector{Float32}()
for face in faces
p2,p1=points[face[1],:],points[face[2],:]
t=p2-p1; n=LinearAlgebra.normalize([-t[2];+t[1]])

p1 = convert(GL.Point3d, [p1; 0.0])
p2 = convert(GL.Point3d, [p2; 0.0])
n = convert(GL.Point3d, [ n; 0.0])

append!(vertices,p1); append!(normals,n)
append!(vertices,p2); append!(normals,n)
end

ret=GL.GLMesh(GL.GL_LINES)
ret.vertices = GL.GLVertexBuffer(vertices)
ret.normals = GL.GLVertexBuffer(normals)
return ret
end


points = rand(50,2)
GL.VIEW([
# GL.GLCuboid(Box3d(GL.Point3d(0,0,0),GL.Point3d(1,1,1)))
GLHull2d(points)
GL.GLAxis(GL.Point3d(0,0,0),GL.Point3d(1,1,1))
])
1 change: 0 additions & 1 deletion src/ViewerGL.jl
@@ -1,7 +1,6 @@
module ViewerGL

using LinearAlgebra

using ModernGL
using GLFW
import Base:*
Expand Down

0 comments on commit 534f8cd

Please sign in to comment.