Hi. I’m Trying to plot a 3D triangle plane using Plots.jl and surface. But an odd extra surface is showing up. Can someone tell-me what i’m doing wrong? Code below with some experiments.
Thanks in advance!!!
using Plots
Plots.PyPlotBackend()
#1st try
struct Point
x::Number
y::Number
z::Number
end
function triangle(p1::Point, p2::Point, p3::Point)
x = [p1.x, p2.x, p3.x, p1.x]
y = [p1.y, p2.y, p3.y, p1.y]
z = [p1.z, p2.z, p3.z, p1.z]
return (x,y,z)
end
A = Point(1,0,0);
B = Point(0,1,0);
C = Point(0,0,1);
tri = triangle(A,B,C)
plot(tri, leg=false, camera = (75,45)) #Fill options doesn't work here in 1st plot???
scatter!(tri, leg=false)
#2nd Try
x = collect(0:0.1:1);
y = collect(0:0.1:1);
z = collect(0:0.1:1);
function make_plane(x,y,z)
a = []
b = []
c = []
for i in x, j in y, k in z
if (i + j + k) == 1
push!(a,i)
push!(b,j)
push!(c,k)
end
end
return a,b,c
end
plane = make_plane(x,y,z)
plot(plane, camera = (60,60)) #I know this is wrong, but adding this 2nd for reference!
surface(plane, camera = (60,60), c = :blues) #this plot 3rd has wrong behavior