Created
February 5, 2016 13:58
besiege上にマンデルブロ集合を描画する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var math = require('mathjs'); | |
var block_id = 1; | |
var scale = 40; | |
var density = 2; | |
function g (x, y) { | |
c = math.complex(x, y); | |
z = math.complex(0, 0); | |
for(var i=0; i<50; i++){ | |
z = math.add( math.multiply(z, z), c); | |
} | |
if((math.abs(z.re) < 2) && (math.abs(z.im) < 2)){ | |
return 1; | |
}else{ | |
return 0; | |
} | |
} | |
var prefab_ids = []; | |
var positions = []; | |
var rotations = []; | |
var is_block_flipped = []; | |
var brace_similar_blocks_start_position = []; | |
var brace_similar_blocks_end_position = []; | |
var machine_world_position = '0,50,0'; | |
var machine_world_rotation = '0'; | |
var keymap_1 = []; | |
var keymap_2 = []; | |
var slider_value = []; | |
var toggle_mode = []; | |
for (var x = -0.5 * scale; x < scale*0.5; x += 1 / density) { | |
for (var y = -0.5 * scale; y < scale*0.5; y += 1 / density) { | |
if(g(x/10, y/10) == 1){ | |
prefab_ids.push(block_id); | |
positions.push((x).toFixed(5)+','+(y).toFixed(5)+','+g(x/10, y/10)); | |
rotations.push('0,0,0,0'); | |
is_block_flipped.push('0'); | |
brace_similar_blocks_start_position.push('90000,90000,90000'); | |
brace_similar_blocks_end_position.push('90000,90000,90000'); | |
keymap_1.push('a'); | |
keymap_2.push('b'); | |
slider_value.push('0'); | |
toggle_mode.push('False'); | |
} | |
} | |
} | |
console.log('PREFAB IDS'); | |
console.log(prefab_ids.join('|')); | |
console.log('POSITIONS'); | |
console.log(positions.join('|')); | |
console.log('ROTATIONS'); | |
console.log(rotations.join('|')); | |
console.log('IS BLOCK FLIPPED'); | |
console.log(is_block_flipped.join('|')); | |
console.log('BRACE + SIMILAR BLOCKS - START POSITION'); | |
console.log(brace_similar_blocks_start_position.join('|')); | |
console.log('BRACE + SIMILAR BLOCKS - END POSITION'); | |
console.log(brace_similar_blocks_end_position.join('|')); | |
console.log('MACHINE WORLD POSITION'); | |
console.log(machine_world_position); | |
console.log('MACHINE WORLD ROTATION'); | |
console.log(machine_world_rotation); | |
console.log('PARAMETER TUNER : KEY MAP 1'); | |
console.log(keymap_1.join('|')); | |
console.log('PARAMETER TUNER : KEY MAP 2'); | |
console.log(keymap_2.join('|')); | |
console.log('PARAMETER TUNER : SLIDER VALUE'); | |
console.log(slider_value.join('|')); | |
console.log('PARAMETER TUNER : TOGGLE MODE'); | |
console.log(toggle_mode.join('|')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment