時代に逆らう人のためのregファイル
最近のWindows Updateが気にくわない
Windows Registry Editor Version 5.00 // コマンドウインドウをここに開くを追加 [HKEY_CLASSES_ROOT\directory\background\shell\CommandPrompt] @="@shell32.dll,-8506" "Extended"="" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\directory\background\shell\CommandPrompt\command] @="cmd.exe /s /k pushd \"%V\"" [HKEY_CLASSES_ROOT\directory\shell\CommandPrompt] @="@shell32.dll,-8506" "Extended"="" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\directory\shell\CommandPrompt\command] @="cmd.exe /s /k pushd \"%V\"" // Windows SearchでBing検索と位置情報とコルタナを無効化 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search] "BingSearchEnabled"=dword:00000000 "AllowSearchToUseLocation"=dword:00000000 "CortanaConsent"=dword:00000000 // 起動時にPin設定を求められないようにする [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\PassportForWork] "Enabled"=dword:00000000
pip install PySide2
いつの間にかPySide2がpip installできるようになっているではありませんか
msbuild (Visual Studio) で並列ビルドが効かない場合
ビルドルールが違うものは並列に実行されないっぽい。例えば同じファイル名のcppが複数あるプロジェクトで出力オブジェクトファイル名を変更していたりするとこの問題にハマることがある。
非弾性衝突
const auto r = (r0 + r1) * 0.5f; // 反発係数 const auto m0 = 1.0f; // Aの質量 const auto m1 = 1.0f; // Bの質量 const auto u0 = n * dot(vel0, n); // 衝突面(法線N)に対しての垂直方向のAの速度 const auto u1 = n * dot(vel1, n); // 衝突面(法線N)に対しての垂直方向のBの速度 const auto v0 = vel0 - u0; // 水平方向のAの速度 const auto v1 = vel1 - u1; // 水平方向のBの速度 const auto f0 = ((u1 - u0) * (r * m1) + (u0 * m0) + (u1 * m1)) / (m0 + m1); // 衝突後の垂直方向のAの速度 const auto f1 = ((u0 - u1) * (r * m0) + (u0 * m0) + (u1 * m1)) / (m0 + m1); // 衝突後の垂直方向のBの速度 vel0 = v0 + f0; // 水平方向と足して新しい速度ベクトルを作成 vel1 = v1 + f1; // 水平方向と足して新しい速度ベクトルを作成
摩擦を考慮する場合は摩擦係数で水平方向のベクトルを減衰させる
2D Perlin Noise in C++
こんな感じやろか?
float interp(float x, float y, float t) { return x + (y - x) * t; // とりあえず線形 } float noise(int32_t x, int32_t y) { auto n = x + y * 57; n = (n << 13) ^ n; return (1.0f - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0f); } float smooth(int32_t x, int32_t y) { float corners = (noise(x - 1, y - 1) + noise(x + 1, y - 1) + noise(x - 1, y + 1) + noise(x + 1, y + 1)) / 16.0f; float sides = (noise(x - 1, y) + noise(x + 1, y) + noise(x, y - 1) + noise(x, y + 1)) / 8.0f; float center = noise(x, y) / 4.0f; return corners + sides + center; } float interpNoise(float x, float y) { auto ix = static_cast<int32_t>(x); auto fx = x - ix; auto iy = static_cast<int32_t>(y); auto fy = y - iy; auto v1 = smooth(ix, iy); auto v2 = smooth(ix + 1, iy); auto v3 = smooth(ix, iy + 1); auto v4 = smooth(ix + 1, iy + 1); auto i1 = interp(v1, v2, fx); auto i2 = interp(v3, v4, fx); return interp(i1, i2, fy); } float perlinNoise(float x, float y, float persistence, int octaves) { float total = 0.0f; for (int i = 0; i < octaves; ++i) { auto f = powf(2.0f, static_cast<float>(i)); auto a = powf(persistence, static_cast<float>(i)); total += interpNoise(x * f, y * f) * a; } return total; }
参考
http://www.technotype.net/hugo.elias/models/m_perlin.html
これは古いやり方(Classic way)と呼ばれていて現在はハッシュテーブルを使った実装が多いようだ
https://mrl.nyu.edu/~perlin/noise/
Understanding Perlin Noise
noise/_perlin.c at master · caseman/noise · GitHub
時間があれば読んでおきたい
Texturing & Modeling A Procedural Approach Third Edition 日本語版