Advertisement
Guest User

sphere.lua

a guest
Sep 27th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. local component = require("component")
  2. local keyboard = require("keyboard")
  3. local shell = require("shell")
  4. local hologram = component.hologram
  5.  
  6. hologram.clear()
  7. --hologram.set(x, y, 20, 2)
  8.  
  9. local r = 10     -- radius
  10. local lats = 20  -- latitude
  11. local longs = 20 -- longitudee
  12.  
  13. for i = 0, lats do
  14.   lat0 = math.pi * (-0.5 + (i - 1) / lats)
  15.   z0 = math.sin(lat0)
  16.   zr0 = math.cos(lat0)
  17.  
  18.   lat1 = math.pi * (-0.5 + i / lats)
  19.   z1 = math.sin(lat1)
  20.   zr1 = math.cos(lat1)
  21.  
  22.   for j = 0, longs do
  23.     lng = 2 * math.pi * (j - 1) / longs
  24.     x = math.cos(lng)
  25.     y = math.sin(lng)
  26.  
  27.     HologramSet(x * zr0, y * zr0, z0)
  28.     HologramSet(x * zr1, y * zr1, z1)
  29.   end
  30.  
  31. end
  32.  
  33. function HologramSet(x, y, z)
  34.   hologram.set(x,y,z,2)
  35.   print("x= " .. x .. " y= " .. y .. " z= " .. z)
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement