function Triangle.SetParent(k,N)k.Beam.Parent=N k.Attachment0.Parent=N k.Attachment1.Parent=N k.Parent=N end function Triangle.SetBeamProperties(k,N)for N,z in next,N do k.Beam[N]=z end end function Triangle.Draw(L,N,k,z)N=N or L.a k=k or L.b z=z or L.c L.a=N L.b=k L.c=z local l,K,w=k-N,z-N,z-k local s,M,O=l:Dot(l),K:Dot(K),w:Dot(w)if s>M and s>O then z,N=N,z elseif M>O and M>s then N,k=k,N end l,K,w=k-N,z-N,z-k local j=(l:Cross(K)).Unit local X=(j:Cross(l)).Unit local b=L.Parent.CFrame:Inverse()L.Attachment0.CFrame=b*CFrame.fromMatrix((N+k)/2,X,l,j)L.Attachment1.CFrame=b*CFrame.new(z)L.Beam.Width0=(N-k).Magnitude end


function Triangle:SetParent(parent)
	self.Beam.Parent = parent
	self.Attachment0.Parent = parent
	self.Attachment1.Parent = parent
	self.Parent = parent
end

function Triangle:SetBeamProperties(properties)
	for prop, value in next, properties do
		self.Beam[prop] = value
	end
end

function Triangle:Draw(a, b, c)
	a = a or self.a
	b = b or self.b
	c = c or self.c
	
	self.a = a
	self.b = b
	self.c = c
	
	local ab, ac, bc = b - a, c - a, c - b
	local abd, acd, bcd = ab:Dot(ab), ac:Dot(ac), bc:Dot(bc)
	
	if (abd > acd and abd > bcd) then
		c, a = a, c
	elseif (acd > bcd and acd > abd) then
		a, b = b, a
	end
	
	ab, ac, bc = b - a, c - a, c - b
	
	local normal = ab:Cross(ac).Unit
	local height = normal:Cross(ab).Unit
	
	local parentInv = self.Parent.CFrame:Inverse()
	self.Attachment0.CFrame = parentInv * CFrame.fromMatrix((a + b)/2, height, ab, normal)
	self.Attachment1.CFrame = parentInv * CFrame.new(c)
	self.Beam.Width0 = (a - b).Magnitude
end
