function Triangle.SetParent(t,k)t.Beam.Parent=k t.Attachment0.Parent=k t.Attachment1.Parent=k t.Parent=k end function Triangle.SetBeamProperties(t,k)for k,i in next,k do t.Beam[k]=i end end function Triangle.Draw(r,k,t,i)k=k or r.a t=t or r.b i=i or r.c r.a=k r.b=t r.c=i local y,M,P=t-k,i-k,i-t local v,F,g=y:Dot(y),M:Dot(M),P:Dot(P)if v>F and v>g then i,k=k,i elseif F>g and F>v then k,t=t,k end y,M,P=t-k,i-k,i-t local E=(y:Cross(M)).Unit local H=(E:Cross(y)).Unit local p=r.Parent.CFrame:Inverse()r.Attachment0.CFrame=p*CFrame.fromMatrix((k+t)/2,H,y,E)r.Attachment1.CFrame=p*CFrame.new(i)r.Beam.Width0=(k-t).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
