ForeverDev

Untitled

Oct 22nd, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | None | 0 0
  1. local abs, sqrt, floor, deg, acos, pow = math.abs, math.sqrt, math.floor, math.deg, math.acos, math.pow
  2.  
  3. local distance = function(point1, point2)
  4.     return floor(abs(sqrt(pow(point2.Y - point1.Y, 2) + pow(point2.X - point1.X, 2))))
  5. end
  6.  
  7. local angle = function(point1, point2)
  8.     return(deg(acos((point2.X - point1.X) / (distance(point1, point2)))))
  9. end
  10.  
  11. local newLine = function(point1, point2)
  12.     local line = Instance.new("TextLabel", script.Parent)
  13.     line.Text = ""
  14.     line.Size = UDim2.new(0, distance(point1, point2), 0, 2)
  15.     line.Position = UDim2.new(0, point1.X --[[ MINUS SOME OFFSET THING HERE?? ]], 0, point1.Y + ((point2.Y - point1.Y) / 2))
  16.     line.Rotation = angle(point1, point2)
  17.    
  18.     --this just draws points so i can see where the line SHOULD be, not relevant
  19.     local x1 = Instance.new("TextLabel", script.Parent)
  20.     x1.Size = UDim2.new(0, 2, 0, 2)
  21.     x1.Position = UDim2.new(0, point1.X, 0, point1.Y)
  22.     x1.Text = ""
  23.     x1.BackgroundColor3 = Color3.new(1, 0, 0)
  24.    
  25.     local x2 = Instance.new("TextLabel", script.Parent)
  26.     x2.Size = UDim2.new(0, 2, 0, 2)
  27.     x2.Position = UDim2.new(0, point2.X, 0, point2.Y)
  28.     x2.Text = ""
  29.     x2.BackgroundColor3 = Color3.new(1, 0, 0)
  30. end
  31.  
  32. newLine(Vector2.new(100, 50), Vector2.new(180, 430))
  33. newLine(Vector2.new(300, 300), Vector2.new(500, 300))
Advertisement
Add Comment
Please, Sign In to add comment