# How to plot a 3D bound plane

Does anyone know how to plot a 3 dimensional bound plane? I’ve found numerous methods for plotting infinite planes but I can’t seem to find one for plotting bound planes. What I’m looking for is a function similar to Matlab’s fill3 command. Basically, I want to be able to pass 3 points -say (0,0,0) (1,1,1) and (0,1,0) and have the function display a triangle bound by those points. Even more ideal would be if I could pass 4 points but if that isn’t possible I could just plot 2 triangles.

Try this.

``````using GeometryTypes
using GLVisualize

show_plane(p1::NTuple{3}, p2::NTuple{3}) = _view(visualize(GLNormalMesh(Quad(Vec(0,0,0), Vec(p1...), Vec(p2...)))),window)

show_plane((1,0,0), (0,1,0))

``````
1 Like

I didn’t know about that package. It looks helpful, except when I run it I get this:

``````LoadError: ModernGL.ContextNotAvailable("glGenBuffers, not available for your driver, or no valid OpenGL context available")
in glGenBuffers(::Int64) at GLExtendedFunctions.jl:108
in GLAbstraction.GLBuffer{FixedSizeArrays.Point{3,Float32}}(::Ptr{FixedSizeArrays.Point{3,Float32}}, ::Int64, ::UInt32, ::UInt32) at GLBuffer.jl:9
in GLAbstraction.GLBuffer{T}(::Array{FixedSizeArrays.Point{3,Float32},1}) at GLBuffer.jl:34
in GLAbstraction.NativeMesh{GeometryTypes.HomogenousMesh{FixedSizeArrays.Point{3,Float32},GeometryTypes.Face{3,UInt32,-1},GeometryTypes.Normal{3,Float32},Void,Void,Void,Void}}(::GeometryTypes.HomogenousMesh{FixedSizeArrays.Point{3,Float32},GeometryTypes.Face{3,UInt32,-1},GeometryTypes.Normal{3,Float32},Void,Void,Void,Void}) at GLUtils.jl:255
in gl_convert(::GeometryTypes.HomogenousMesh{FixedSizeArrays.Point{3,Float32},GeometryTypes.Face{3,UInt32,-1},GeometryTypes.Normal{3,Float32},Void,Void,Void,Void}) at GLUniforms.jl:183
in GLAbstraction.RenderObject{Pre}(::Dict{Symbol,Any}, ::GLVisualize.GLVisualizeShader, ::GLAbstraction.StandardPrerender, ::Void, ::Reactive.Signal{GeometryTypes.HyperRectangle{3,Float32}}, ::Void) at GLTypes.jl:291
in assemble_robj(::Dict{Symbol,Any}, ::GLVisualize.GLVisualizeShader, ::Reactive.Signal{GeometryTypes.HyperRectangle{3,Float32}}, ::UInt32, ::Void, ::Void) at utils.jl:36
in visualize(::Any, ::GLAbstraction.Style{:default}, ::Dict{Symbol,Any}) at visualize_interface.jl:21
in visualize(::Any, ::Symbol) at visualize_interface.jl:20
in visualize(::Any) at visualize_interface.jl:20
in show_plane(::Tuple{Int64,Int64,Int64}, ::Tuple{Int64,Int64,Int64}) at untitled:4
in include_string(::Module, ::String, ::String) at eval.jl:34
in (::Atom.##59#62{String,String})() at eval.jl:73
in withpath(::Atom.##59#62{String,String}, ::String) at utils.jl:30
in withpath(::Function, ::String) at eval.jl:38
in macro expansion at eval.jl:71 [inlined]
``````

My bad, here is the full code:

``````using GeometryTypes
using GLVisualize

window = glscreen()
@async renderloop(window)

show_plane(origin::NTuple{3}, point1::NTuple{3}, point2::NTuple{3}) = _view(visualize(GLNormalMesh(Quad(Vec(origin...), Vec(point1...), Vec(point2...)))),window)
show_plane((0,0,0), (1,0,0), (0,1,0))
show_plane((0,0,0), (1,1,0), (0,1,1))
``````

First plane will be really really slow, then all others will be fast.

``````using Plots
pyplot() # for interactivity
surface([(0,0,0),(1,1,1), (0,1,0)])
``````

If you want 4 points, just pass 4 points.

1 Like