SHOW:
|
|
- or go back to the newest paste.
1 | - | local component = require("component") |
1 | + | local component = require("component") |
2 | - | local keyboard = require("keyboard") |
2 | + | local keyboard = require("keyboard") |
3 | - | local shell = require("shell") |
3 | + | local shell = require("shell") |
4 | - | local hologram = component.hologram |
4 | + | local hologram = component.hologram |
5 | - | |
5 | + | |
6 | - | hologram.clear() |
6 | + | hologram.clear() |
7 | - | --hologram.set(x, y, 20, 2) |
7 | + | --hologram.set(x, y, 20, 2) |
8 | - | |
8 | + | |
9 | - | local r = 10 -- radius |
9 | + | function round(num, idp) |
10 | - | local lats = 20 -- latitude |
10 | + | local mult = 10^(idp or 0) |
11 | - | local longs = 20 -- longitudee |
11 | + | return math.floor(num * mult + 0.5 ) / mult |
12 | - | |
12 | + | end |
13 | - | for i = 0, lats do |
13 | + | function HologramSet(x, y, z) |
14 | - | lat0 = math.pi * (-0.5 + (i - 1) / lats) |
14 | + | -- hologram.set(round(x),round(y),round(z),2) |
15 | - | z0 = math.sin(lat0) |
15 | + | hologram.set(x,y,z,2) |
16 | - | zr0 = math.cos(lat0) |
16 | + | print("x= " .. x .. " y= " .. y .. " z= " .. z) |
17 | - | |
17 | + | end |
18 | - | lat1 = math.pi * (-0.5 + i / lats) |
18 | + | |
19 | - | z1 = math.sin(lat1) |
19 | + | local r = 10 -- radius |
20 | - | zr1 = math.cos(lat1) |
20 | + | local lats = 50 -- latitude |
21 | - | |
21 | + | local longs = 50 -- longitude |
22 | - | for j = 0, longs do |
22 | + | local sx = 24 |
23 | - | lng = 2 * math.pi * (j - 1) / longs |
23 | + | local sy = 24 |
24 | - | x = math.cos(lng) |
24 | + | local sz = 15 |
25 | - | y = math.sin(lng) |
25 | + | |
26 | - | |
26 | + | for i = 1, lats do |
27 | - | HologramSet(x * zr0, y * zr0, z0) |
27 | + | lat0 = math.pi * (-0.5 + (i - 1) / lats) |
28 | - | HologramSet(x * zr1, y * zr1, z1) |
28 | + | z0 = math.sin(lat0) |
29 | - | end |
29 | + | zr0 = math.cos(lat0) |
30 | - | |
30 | + | |
31 | lat1 = math.pi * (-0.5 + i / lats) | |
32 | - | |
32 | + | z1 = math.sin(lat1) |
33 | - | function HologramSet(x, y, z) |
33 | + | zr1 = math.cos(lat1) |
34 | - | hologram.set(x,y,z,2) |
34 | + | |
35 | - | print("x= " .. x .. " y= " .. y .. " z= " .. z) |
35 | + | for j = 1, longs do |
36 | lng = 2 * math.pi * (j - 1) / longs | |
37 | x = math.cos(lng) | |
38 | y = math.sin(lng) | |
39 | ||
40 | HologramSet(x * zr0 * r + sx, y * zr0 * r + sy, z0 * r + sz) | |
41 | HologramSet(x * zr1 * r + sx, y * zr1 * r + sy, z1 * r + sz) | |
42 | end | |
43 | ||
44 | end |