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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using MathNet.Numerics; | |
using MathNet.Numerics.LinearAlgebra; | |
public class ProjectiveTransform : MonoBehaviour | |
{ | |
GameObject q1_obj; |
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
#include <stdio.h> | |
int main() { | |
double xn = 1.0; | |
double yn = 0.0; | |
double t = 0.0; | |
double dt = 0.01; | |
double k = 1.0; | |
double x = xn; | |
double y = yn; |
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
#include <iostream> | |
#include <GL/glew.h> | |
#include <GL/glut.h> | |
#include <oglplus/all.hpp> | |
oglplus::Context* gl; | |
void Display(void); | |
int main(int argc, char* argv[]){ |
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
function fileSave(text, filename){ | |
var blob = new Blob([text],{"type" : "text/html"}); | |
var newElement = document.createElement("a"); // 新しいDOMを作成 | |
newElement.textContent= "download"; // テキストはdownload | |
newElement.setAttribute('href', window.URL.createObjectURL(blob)); | |
newElement.setAttribute('download', filename); | |
document.body.appendChild(newElement); // body直下に作成 | |
} |
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
// ドロネー三角形分割関数 | |
// ※簡潔だが効率の悪い実装 | |
// 引数1 inputPoints: 入力点の座標 [[x1,y1],[x2,y2],....] | |
// 引数2,3,4,5 ymax, ymin, xmax, xmin: 入力点が含まれる領域の最大・最小座標 | |
// 返り値:triangleのコネクティビティ | |
// 返り値の例: [[0,1,2], [0,1,3], [1,2,4]..] の場合, | |
// inputPoints[0], inputPoints[1], inputPoints[2] が三角形1を構成する。…以下、同様 | |
function DelaunayTriangulation(inputPoints, ymax, ymin, xmax, xmin) { | |
var pos = numeric.clone(inputPoints); // 点の数 x 2(x,y) |
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
// サイズ NxN の行列 A の逆行列を計算する | |
// ピボット選択なし | |
// 実際にはnumeric javascript の numeric.inverse() や numeric.solve() を使うべき | |
function inverseGaussJordan(A, N) { | |
var U=numeric.clone(A); | |
var Ainv=identityMatrix(N); | |
var alpha; | |
var diagValue; | |
for(var i=0; i<N; ++i) { | |
diagValue=U[i][i]; |
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
// 入力誤差モデルを用いた最尤推定による直線当てはめ | |
// 入力 データ点 points = [[x0,y0],[x1,y1],...,[xn-1,yn-1]] | |
// y = ax + b の a, b を格納した配列 [a,b] を返す | |
function lineFittingInputErrorModel(points) { | |
// 点の数 | |
var N=points.length; | |
// xの重心 |
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
// 3次スプライン補間 | |
// 参考:高橋大輔,数値計算,岩波書店,1996. | |
// 入力 N+1個の点列 points = [[x0,y0],[x1,x2],...,[xn,yn]] | |
// 出力 各データ点間の区間における多項式の係数を含む2次元配列 | |
// x:x座標値で昇順ソートされた点列のx座標 | |
// y:x座標値で昇順ソートされた点列のy座標 | |
// a:区間[x_i+1 - x_i]における3次式の係数 配列サイズN-1 | |
// b:区間[x_i+1 - x_i]における3次式の係数 配列サイズN-1 | |
// c:区間[x_i+1 - x_i]における3次式の係数 配列サイズN-1 | |
// d:区間[x_i+1 - x_i]における3次式の係数 配列サイズN-1 |
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
// ラグランジュ補間(と等価な多項式補間) | |
// 入力 N個の点列 points = [[x0,y0],[x1,x2],...,[xn-1,yn-1]] | |
// 出力 多項式の係数配列c | |
// y = c[0]*x^N-1 + c[1]*x^N-2 + ... + c[N-2]*x + c[N-1] | |
function lagrangeInterpolation(points) { | |
var dim=points.length; | |
var A=numeric.rep([dim, dim], 0); | |
var b=numeric.rep([dim], 0); | |
for(var i=0; i<dim; ++i) { | |
for(var j=0; j<dim; ++j) { |
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
// numeric.jsを使用 | |
// データ点を配列で渡す 例: points = [[x0,y0],[x1,y1],[x2,y2],[x3,y3]]; | |
// 多項式の係数を配列で返す | |
// dim=2 -> 直線 | |
// dim=3 -> 二次曲線 | |
function leastSquareN(points, dim) { | |
if(points.length<dim) { | |
return numeric.rep([dim], 0); | |
} | |
var A=numeric.rep([dim, dim], 0); |
NewerOlder