--


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
