This file contains hidden or 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 model = { | |
observers: new Array(), | |
position: null, | |
text: null, | |
queue: null, | |
running: false, | |
start: function() { | |
if (this.running) return; | |
this.running = true; | |
this.queue = [ |
This file contains hidden or 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 controller = { | |
click: function() { | |
model.start(); | |
}, | |
next: function() { | |
model.next(); | |
} | |
}; |
This file contains hidden or 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 view = { | |
update: function() { | |
var t = model.text; | |
$('#label').text(t); | |
var p = model.position; | |
$('#lame').animate( | |
{left: p.x, top: p.y}, | |
{duration: 'slow', complete: function(){controller.next()}} | |
); | |
} |
This file contains hidden or 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
public class Node | |
{ | |
public string Name { get; private set; } | |
public ICollection<Node> Neighbors { get; private set; } | |
public Node(string name) | |
{ | |
this.Name = name; | |
this.Neighbors = new List<Node>(); | |
} |
This file contains hidden or 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
public class NodeCollection : Dictionary<string, Node> | |
{ | |
public NodeCollection Add(params string[] names) | |
{ | |
foreach (string name in names) | |
{ | |
this[name] = new Node(name); | |
} | |
return this; | |
} |
This file contains hidden or 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
static NodeCollection CreateGraph() | |
{ | |
return new NodeCollection() | |
.Add("a", "a'", "b", "b'", "c", "c'", | |
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", | |
"10", "11", "12", "13", "14", "15", "16", "17", "18", "19", | |
"20", "21", "22", "23", "24", "25", "26", "27", "28", "29") | |
.Link("0,1", "0,10", "0,21", "1,2", "1,28", | |
"2,3", "2,6", "3,4", "3,b'", "4,5", | |
"4,8", "5,6", "5,7", "6,11", "7,14", |
This file contains hidden or 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
public class Node | |
{ | |
public string Name { get; private set; } | |
public ICollection<Node> Neighbors { get; private set; } | |
public Vector R { get; set; } | |
public Vector V { get; set; } | |
public Node(string name) | |
{ |
This file contains hidden or 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
public class Node | |
{ | |
public void MoveEular(double dt, Vector f) | |
{ | |
// 質量は1とする | |
this.R = new Vector() | |
{ | |
X = this.R.X + dt * this.V.X, | |
Y = this.R.Y + dt * this.V.Y | |
}; |
This file contains hidden or 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
public class Node | |
{ | |
public Vector GetSpringForce(Node n) | |
{ | |
// ばねの力は自然長からの変位に比例 (比例定数 -k, ばねの長さ l) | |
const double k = 0.1d; | |
const double l = 60.0d; | |
double dx = this.R.X - n.R.X; | |
double dy = this.R.Y - n.R.Y; | |
double d2 = dx * dx + dy * dy; |
This file contains hidden or 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
public class Node | |
{ | |
public Vector GetReplusiveForce(Node n) | |
{ | |
// 反発は距離の2乗に反比例 (比例定数 g) | |
const double g = 500.0d; | |
double dx = this.R.X - n.R.X; | |
double dy = this.R.Y - n.R.Y; | |
double d2 = dx * dx + dy * dy; | |
if (d2 < double.Epsilon) |
OlderNewer