概要
plunkerでthree.jsやってみた。
練習問題やってみた。
練習問題
モデリング言語で、球を作れ。
写真
サンプルコード
process.stdin.resume();
process.stdin.setEncoding('utf8');
var r = 100;
var n2 = 5;
var n3 = n2 + 1;
var n4 = n2 + 2;
var n5 = n2 + 3;
for (let j = 0; j < n4; j++)
{
let d = Math.sin((j / n3) * Math.PI)
let y = Math.cos((j / n3) * Math.PI) * r
for (let i = 0; i < n4; i++)
{
let x = Math.cos((i / n3) * Math.PI * 2) * r * d
let z = Math.sin((i / n3) * Math.PI * 2) * r * d
console.log("p", x, y, z);
}
}
for (let j = 0; j < n3; j++)
{
for (let i = 0; i < n4; i++)
{
var b = i + j * n4 + 1;
if (b == 42)
n5 = n4;
console.log("s", b, b + 1, b + n4, b + n5);
}
}
実行結果
p 0 100 0
p 0 100 0
p -0 100 0
p -0 100 0
p -0 100 -0
p 0 100 -0
p 0 100 -0
p 49.99999999999999 86.60254037844388 0
p 25.000000000000004 86.60254037844388 43.301270189221924
p -24.999999999999986 86.60254037844388 43.30127018922193
p -49.99999999999999 86.60254037844388 6.123233995736765e-15
p -25.000000000000018 86.60254037844388 -43.30127018922192
p 25.000000000000004 86.60254037844388 -43.301270189221924
p 49.99999999999999 86.60254037844388 -1.224646799147353e-14
p 86.60254037844386 50.000000000000014 0
p 43.301270189221945 50.000000000000014 75
p -43.30127018922191 50.000000000000014 75
p -86.60254037844386 50.000000000000014 1.0605752387249068e-14
p -43.30127018922197 50.000000000000014 -74.99999999999999
p 43.301270189221945 50.000000000000014 -75
p 86.60254037844386 50.000000000000014 -2.1211504774498136e-14
p 100 6.123233995736766e-15 0
p 50.000000000000014 6.123233995736766e-15 86.60254037844386
p -49.99999999999998 6.123233995736766e-15 86.60254037844388
p -100 6.123233995736766e-15 1.2246467991473532e-14
p -50.00000000000004 6.123233995736766e-15 -86.60254037844385
p 50.000000000000014 6.123233995736766e-15 -86.60254037844386
p 100 6.123233995736766e-15 -2.4492935982947064e-14
p 86.60254037844388 -49.99999999999998 0
p 43.301270189221945 -49.99999999999998 75
p -43.30127018922192 -49.99999999999998 75.00000000000001
p -86.60254037844388 -49.99999999999998 1.060575238724907e-14
p -43.301270189221974 -49.99999999999998 -74.99999999999999
p 43.301270189221945 -49.99999999999998 -75
p 86.60254037844388 -49.99999999999998 -2.121150477449814e-14
p 49.99999999999999 -86.60254037844388 0
p 25.000000000000004 -86.60254037844388 43.301270189221924
p -24.999999999999986 -86.60254037844388 43.30127018922193
p -49.99999999999999 -86.60254037844388 6.123233995736765e-15
p -25.000000000000018 -86.60254037844388 -43.30127018922192
p 25.000000000000004 -86.60254037844388 -43.301270189221924
p 49.99999999999999 -86.60254037844388 -1.224646799147353e-14
p 1.2246467991473532e-14 -100 0
p 6.123233995736768e-15 -100 1.0605752387249068e-14
p -6.123233995736764e-15 -100 1.060575238724907e-14
p -1.2246467991473532e-14 -100 1.4997597826618577e-30
p -6.123233995736772e-15 -100 -1.0605752387249066e-14
p 6.123233995736768e-15 -100 -1.0605752387249068e-14
p 1.2246467991473532e-14 -100 -2.9995195653237154e-30
s 1 2 8 9
s 2 3 9 10
s 3 4 10 11
s 4 5 11 12
s 5 6 12 13
s 6 7 13 14
s 7 8 14 15
s 8 9 15 16
s 9 10 16 17
s 10 11 17 18
s 11 12 18 19
s 12 13 19 20
s 13 14 20 21
s 14 15 21 22
s 15 16 22 23
s 16 17 23 24
s 17 18 24 25
s 18 19 25 26
s 19 20 26 27
s 20 21 27 28
s 21 22 28 29
s 22 23 29 30
s 23 24 30 31
s 24 25 31 32
s 25 26 32 33
s 26 27 33 34
s 27 28 34 35
s 28 29 35 36
s 29 30 36 37
s 30 31 37 38
s 31 32 38 39
s 32 33 39 40
s 33 34 40 41
s 34 35 41 42
s 35 36 42 43
s 36 37 43 44
s 37 38 44 45
s 38 39 45 46
s 39 40 46 47
s 40 41 47 48
s 41 42 48 49
s 42 43 49 49
成果物
以上