function Triangle.SetParent(e,c)e.WedgeA.Parent=c e.WedgeB.Parent=c e.Parent=c end function Triangle.SetWedgeProperties(e,c)for c,b in next,c do e.WedgeA[c]=b e.WedgeB[c]=b end end function Triangle.Draw(W,c,e,b)c=c or W.a e=e or W.b b=b or W.c W.a=c W.b=e W.c=b local i=W.WedgeA local Q=W.WedgeB local n,P,u=e-c,b-c,b-e local s,j,w=n:Dot(n),P:Dot(P),u:Dot(u)if s>j and s>w then b,c=c,b elseif j>w and j>s then c,e=e,c end n,P,u=e-c,b-c,b-e local X=(P:Cross(n)).Unit local O=(u:Cross(X)).Unit local l=u.Unit local I=math.abs(n:Dot(O))local r=math.abs(n:Dot(l))local L=math.abs(P:Dot(l))i.Size=Vector3.new(.05,I,r)i.CFrame=CFrame.fromMatrix((c+e)/2,X,O,l)i.Parent=W.Parent Q.Size=Vector3.new(.05,I,L)Q.CFrame=CFrame.fromMatrix((c+b)/2,-X,O,-l)Q.Parent=W.Parent end


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
