jig487

interpolateDemo

Oct 10th, 2021 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. local tArgs = {...}
  2. local p1 = vector.new(tArgs[1],tArgs[2],tArgs[3])
  3. local p2 = vector.new(tArgs[4],tArgs[5],tArgs[6])
  4. local p3 = vector.new(tArgs[7],tArgs[8],tArgs[9])
  5.  
  6. local function interpolate(p1x,p1y,p2x,p2y,x)
  7. return p1y + ( ((p2y-p1y)/(p2x-p1x)) * (x-p1x) )
  8. end
  9.  
  10. term.clear()
  11. for y = p2.y, p1.y do
  12. for x = interpolate(p1.x,p1.y,p2.x,p2.y,y), interpolate(p1.x,p1.y,p3.x,p3.y,y) do
  13. term.setCursorPos(x,y)
  14. term.write("#")
  15. end
  16. end
Add Comment
Please, Sign In to add comment