robot arm

body = new THREE.Object3D();
var bodyLength = 60;

createRobotBody( body, bodyLength, robotBodyMaterial );

arm.position.y = bodyLength;
body.add( arm );

scene.add( body );
handRight = new THREE.Object3D();
createRobotGrabber( handRight, handLength, robotHandRightMaterial );
handRight.position.y = faLength;
forearm.add( handRight );

handRight.rotation.z = effectController.hz * Math.PI/180;
handRight.position.z = -effectController.htz;
var flower = new THREE.Object3D();

for (var i = 0; i < 24; i++ )
{
	var cylinder = new THREE.Mesh( cylGeom, petalMaterial );
	cylinder.position.y = petalLength / 2;

	var petal = new THREE.Object3D();
	petal.add( cylinder );
	petal.rotation.z = 90 * Math.PI/180;
	petal.rotation.y = 15*i * Math.PI/180;
	petal.position.y = flowerHeight;

	flower.add( petal );
}
var maxCorner = new THREE.Vector3( 1, 1, 1);
var minCorner = new THREE.Vector3( -1, -1, -1 );
var cylAxis = new THREE.Vector3();
cylAxis.subVectors( maxCorner, minCorner );
var cylLength = cylAxis.length();

cylAxis.normalize();
var theta = Math.acos(
	cylAxis.dot( new THREE.Vector3(0,1,0)));
var cylinder = new THREE.Mesh(
	new THREE.CylinderGeometry(0.2, 0.2, cylLength, 32), cylinderMaterial );

var rotationAxis = new THREE.Vector3(1,0,-1);
rotationAxis.normalize();
cylinder.matrixAutoUpdate = false;
cylinder.matrix.makeRotationAxis( rotationAxis, theta);
var cylinder = new THREE.Mesh(
	new THREE.CylinderGeometry(0.2, 0.2, cylLength, 32), cylinderMaterial );
for ( var i = 0; i < 4; i++ )
{
	var cylinder = new THREE.Mesh( cylinderGeo, cylinderMaterial );

	var x = (i < 2) ? -1: 1;
	var z = (i % 2) ? -1: 1;
	var rotationAxis = new THREE.Vector3(x,0,z);
	rotationAxis.normalize();

	cylinder.matrixAutoUpdate = false;
	cylinder.matrix.makeRotationAxis( rotationAxis, theta );

	scene.add( cylinder ); 
}
var cylAxis = new THREE.Vector3();
cylAxis.subVectors( top, bottom );
var length = cylAxis.length();

var center = new THREE.Vector3();
center.addVectors( top, bottom );
center.divideScalar( 2.0 );
var capsule = new THREE.Object3D();
capsule.add( cyl );
if(!openTop || !openBottom ){
	var sphGeom = new THREE.SphereGeometry(radius, segmentsWidth, segmentsWidth/2);
	if ( !openTop){
		var sphTop = new THREE.MESH( sphGeom, material);
		sphTop.position.set( top.x, top.y, top.z );
		capsule.add( sphTop );
	}
	if ( !openBottom ){
		var sphBottom = new THREE.Mesh( sphGeom, material );
		sphBottom.position.set( bottom.x, bottom.y, bottom.z );
		capsule.add( sphBottom );
	}
}
return capsule;

var helix = new THREE.Object3D();
var bottom = new THREE.Vector3();
var top = new THREE.Vector3();
var openBottom = false;
var openTop = false;
var sine_sign = false;
bottom.set( radius, -height/2, 0);
for (var i = 1; i <= arc*radicalSegment ; i++ ) { top.set(radius * Math.cos( i * 2 * Math.PI/ radialSegments ), height * (i / (arc*radialSegments)) - height/2, sine_sign * radius * Math.sin(i * 2*Math.PI/ radialSegments)); var capsule = createCapsule(material, tube, top, bottom, tubularSegments, OpenTop, openBottom ); helix.add ( capsule ); openBottom = true; bottom.copy( top ); } return helix; [/javascript]

cylinder = new THREE.Mesh(
	new THREE.CylinderGeometry(5, 5, 200, 32), crossbarMaterial);
	cylinder.position.set(0, 360, 0);
	cylinder.rotation.x = 90 * Math.PI / 180.0;
	scene.add( cylinder );

cylinder = new THREE.Mesh(
	new THREE.CylinderGeometry(6, 14, 70, 32), headMaterial);
cylinder.position.set( -70, 530, 0);
cylinder.rotation.z = 90 * Math.PI / 180.0;
scene.add( cylinder );

Vertext

var color1 = new THREE.Color( 0xF08000);
var color2 = new THREE.Color( 0x808000);
var color3 = new THREE.Color( 0x0982FF);

geometry.faces[0].vertexColors = [ color1, color2, color3 ];
var glassMaterial = new THREE.MeshPhongMaterial({ color: 0x0, specular: 0xFFFFFF,
    shininess: 100, opacity: 0.3, transparent: true});
cube.rotation.y = -60 * Math.PI/180;
scene.add( cube );

Pi is a number – approximately 3.142. It is the circumference of any circle divided by its diameter. The number Pi, denoted by the Greek letter π – pronounced ‘pie’, is one of the most common constants in all of mathematics. It is the circumference of any circle, divided by its diameter.

plane.rotation.x = 20 * Math.PI / 180;
plane.rotation.y = -12 * Math.PI / 180;
plane.rotation.z = 71 * Math.PI / 180;

The Euler angles are three angles introduced by Leonhard Euler to describe the orientation of a rigid body with respect to a fixed coordinate system. They can also represent the orientation of a mobile frame of reference in physics or the orientation of a general basis in 3-dimensional linear algebra.

sphere.scale.x = 3.0;
sphere.scale.y = 0.2;
sphere.scale.z = 0.2;
sphere.rotation.y = 30 * Math.PI/180;

scene.add( sphere );
box.position.x = 3.0;
box.rotation.y = 5.7;
cylinder.position.y = 50;
cylinder.rotation.x = 90 : Math.PI/180;
var block = new THREE.Mesh(
	new THREE.CubeGeometry(1000, 4, 4), clockHandMaterial );

block.position.x = 40;

var clockHand = new THREE.Object3D();
clockHand.add( block );

clockHand.rotation.y = -70 * Math.PI/180;
scene.add( clockHand );
var minuteHand = new THREE.object3D();
minuteHand.add( cube );

minuteHand.rotation.y = -60 * Math.PI/180;
scene.add( minuteHand );

var shpere = new THREE.Mesh(
	new THREE.SphereGeometry(0.5, 32, 16), hourHandMaterial );
sphere.position.y = 18;

sphere.scale.x = 50;
sphere.scale.y = 4;
sphere.scale.z = 4;
sphere.position.x = 50/2 - 10;

var hourHand = new THREE.Object3D();
hourHand.add( sphere );

hourHand.rotation.y = 30 * Math.PI/180;
scene.add( hourHand);
var lamp = new THREE.Object3D();
var cylinderGeometry = new THREE.CylinderGeometry( 20, 20, 100, 32 );
for ( i = 0; i < 10; i++ )
{
	var clinder = new THREE.Mesh( cylinderGeometry, cylinderMaterial );
	cylinder.rotation.x = 20 * i * Math.PI/180;
	lamp.add( cylinder );
}
forearm = new THREE.Object3D();
var faLength = 80;
createRobotExtender( forearm, faLength, robotForearmMaterial );
scene.add( forearm );

Geometry

// defining geometry
var triangleGeometry = new THREE.geometry();
// verticles
triangleGeometry.verticle.push( new THREE.Vector3( 1, 1, 0 ));
triangleGeometry.verticle.push( new THREE.Vector3( 3, 1, 0 ));
triangleGeometry.verticle.push( new THREE.Vector3( 3, 3, 0 ));
// face
triangleGeometry.faces.push( new THREE.Face3( 0, 1, 2) );
var x = radius * Math.cos(angle) + location.x;
var y = radius * Math.sin(angle) + location.y;
var sphereMaterial = new THREE.MeshLamberMaterial();

sphereMaterial.color.r = 1.0;
sphereMaterial.color.g = 1.0;
sphereMaterial.color.b = 0.5;

web GL

GL stand for graphic library
https://get.webgl.org/

FPS frame rate per second
Motion blur is the apparent streaking of rapidly moving objects in a still image or a sequence of images such as a movie or animation.

three.js
https://threejs.org/examples/

VideoGames
30 or 60 FPS
Monitors: 60 Hertz
FILM: 24FPS, 48 or 72Hz

fpsとは、画像を1秒間に何回書き換えているか表したもの

var camera, scene, renderer;
var windowScale;
var cameraControls;
var clock = new THREE.Clock();

function drawGoldCube() {

    var cube;
    var cubeSizeLength = 100;
    var goldColor = "#FFDF00";
    var showFrame = true;
    var wireMaterial = new THREE.MeshBasicMaterial( { color: goldColor, wireframe: showFrame } ) ;

    var cubeGeometry = new THREE.CubeGeometry(cubeSizeLength, cubeSizeLength, cubeSizeLength);

    cube = new THREE.Mesh( cubeGeometry, wireMaterial );
    cube.position.x = 0;    // centered at origin
    cube.position.y = 0;    // centered at origin
    cube.position.z = 0;    // centered at origin
    scene.add( cube ;

}

function init() {
    var canvasWidth = 846;
    var canvasHeight = 494;
    // For grading the window is fixed in size; here's general code:
    //var canvasWidth = window.innerWidth;
    //var canvasHeight = window.innerHeight;
    var canvasRatio = canvasWidth / canvasHeight;
    // SCENE
    scene = new THREE.Scene();
    scene.fog = new THREE.Fog( 0x808080, 2000, 4000 );
    // LIGHTS
    scene.add( new THREE.AmbientLight( 0x222222 ) );

    // RENDERER
    renderer = new THREE.WebGLRenderer( { antialias: true } );
    renderer.gammaInput = true;
    renderer.gammaOutput = true;
    renderer.setSize(canvasWidth, canvasHeight);
    renderer.setClearColor( scene.fog.color, 1 );

    var container = document.getElementById('container');
    container.appendChild( renderer.domElement );


    // CAMERA
    camera = new THREE.PerspectiveCamera( 45, canvasRatio, 1, 4000 );
    camera.position.set( -200, 200, -150 );
    // CONTROLS
    cameraControls = new THREE.OrbitAndPanControls(camera, renderer.domElement);
    cameraControls.target.set(0,0,0);

    / draw the coordinate grid
    Coordinates.drawGrid({size:1000,scale:0.01});
    Coordinates.drawGrid({size:1000,scale:0.01, orientation:"y"});
    Coordinates.drawGrid({size:1000,scale:0.01, orientation:"z"});
}

function animate() {
    requestAnimationFrame(animate);
    render();
}

function render() {
    var delta = clock.getDelta();
    cameraControls.update(delta);
    renderer.render(scene, camera);
}

init();
drawGoldCube();
animate();

Git command

workspace, index, local repository, remote repository

add (-u)
commit
commit -a
push
fetch
merge

create git name
git config –global user.name “”
git config –global user.email “”

\app> git status
On branch master

Initial commit

Untracked files:
  (use "git add ..." to include in what will be committed)

        README.txt

nothing added to commit but untracked files present (use "git add" to track)

\app> git commit
[master (root-commit) aba9fda] add file
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README.txt
\app> git status
On branch master
nothing to commit, working directory clean

\\app> git status
On branch master
Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)

        modified:   README.txt

no changes added to commit (use "git add" and/or "git commit -a")

\app> git commit -a -m “Added README content”
[master 776f72d] Added README content
1 file changed, 1 insertion(+)

introduction, user requirement, system indification

Technical Process

1. Clarifying the Question
2. Confirming Input
3. Test Cases
4. Brainstorming
5. Runtime Analysis
6. Coding
7. Debugging
8. Wrap-up

history of software bugs
http://archive.wired.com/software/coolapps/news/2005/11/69355?currentPage=all

Binary Tree

class Node(object):
    def __init__(self, value):
        self.value = value
        self.left = None
        self.right = None

class BinaryTree(object):
    def __init__(self, root):
        self.root = Node(root)

    def search(self, find_val):
        return self.preorder_serach(tree.root, find_val)

    def print_tree(self):
        return self.preorder_print(tree.root, "")[:-1]

    def preorder_search(self, start, find_val):
        if start:
            if start.value == find_val:
                return True
            else
                return self.preorder_search(start.left, find_val) or self.preorder_search(start.right, find_val)
            return False                

    def preorder_print(self, start, traversal):
        if start:
            traversal += (str(start.value) + "-")
            traversal = self.preorder_print(start.left, traversal)
            traversal = self.preorder_print(start.right, traversal)
        return traversal

Binary Search Tree

class Node(object):
    def __init__(self, value):
        self.value = value
        self.left = None
        self.right = None

class BST(object):
    def __init__(self, root):
        self.root = Node(root)

    def insert(self, new_val):
        self.insert_helper(self.root, new_val)

    def insert_helper(self, current, new_val):
        if current_value < new_val:
            if current.right:
                self.insert_helper(current.right, new_val)
            else:
                current.right = Node(new_val)

        else:
            if current.left:
                self.insert_helper(current.left, new_val)
            else:
                current.left = Node(new_val)

    def search(self, find_val):
        return self.search_helper(self.root, find_val)

    def search_helper(self, current, find_val):
        if current:
            if current.value == find_val:
                return True
            elif current.value < find_val:
                return self.search_helper(current.right, find_val)
            else:
                return self.search_helper(current.left, find_val)
        return False

graph(network): how things is connect one another which is similar to tree.

0[0, 1, 0, 0]
1[1, 0, 1, 1]
2[0, 1, 0, 1]
3[0, 1, 1, 0]

Dictionary

In Python, the map concept appears as a built-in data type called a dictionary. A dictionary contains key-value pairs. Dictionaries is extremely easy to use and useful. Here’s a sample of setting up a dictionary.

locations = {'North America': {'USA': ['Mountain View']}}
locations['North America']['USA'].append('Atranta')
locations['Asia'] = {'India': ['Bangalore']}
locations['Asia']['China'].append = ['Shanghai']
locations['Africa'] = {'Egypt': ['Cairo']}

usa_sorted = sorted(locations['North America']['USA'])
for city in usa_sorted
    print city

asia_cities = []
for countries, cities in location['Asia'].iteritems():
    city_country = cities[0] + " - " + countries
    asia_cities.append(city_country)
asia_sorted = sorted(asia_cities)
for city in asia_sorted:
    print city

When hash table collision, bucket store data.

Hash Value = (ASCII Value of First Letter * 100) + ASCII Value of Second Letter

hash table

class HashTable(object):
    def __init__(self):
        self.table = [None]*10000

    def store(self, string):
        hv = self.calculate_hash_value(string)
        if hv != -1:
            if self.table[hv] != None:
                self.table[hv].append(string)
            else
                self.table[hv] = [string]

    def lookup(self, string):
        hv = slef.calculate_hash_value(string)
        if hv != -1:
            if self.table[hv] != None:
                if string in self.table[hv]:
                    return hv
        return -1

    def calculate_hash_value(self, string):
        value = ord(string[0])* 100 + ord(string[1])
        return -1

Tree DFS, In-order