--


function Triangle:SetParent(parent)
	self.WedgeA.Parent = parent
	self.WedgeB.Parent = parent
	self.Parent = parent
end

function Triangle:SetWedgeProperties(properties)
	for prop, value in next, properties do
		self.WedgeA[prop] = value
		self.WedgeB[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 wedgeA = self.WedgeA
	local wedgeB = self.WedgeB
	
	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 right = ac:Cross(ab).Unit
	local up = bc:Cross(right).Unit
	local back = bc.Unit
	
	local height = math.abs(ab:Dot(up))
	local width1 = math.abs(ab:Dot(back))
	local width2 = math.abs(ac:Dot(back))
	
	wedgeA.Size = Vector3.new(0.05, height, width1)
	wedgeA.CFrame = CFrame.fromMatrix((a + b)/2, right, up, back)
	wedgeA.Parent = self.Parent
	
	wedgeB.Size = Vector3.new(0.05, height, width2)
	wedgeB.CFrame = CFrame.fromMatrix((a + c)/2, -right, up, -back)
	wedgeB.Parent = self.Parent
end
