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
<!DOCTYPE html> | |
<html> | |
<head></head> | |
<body style="background: black;"> | |
<canvas id="canvas" width="500" height="500"></canvas> | |
<script> | |
const el = document.getElementById("canvas"); | |
// ctx.fillRect(0, 0, 500, 500); | |
const vertexes = [ | |
{x: 100, y: 100, c: [0, 0, 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
fn distance_on_sphere(lat1: f32, lon1: f32, lat2: f32, lon2: f32) -> f32 { | |
let dlat = (lat2 - lat1).abs(); | |
let dlon = (lon2 - lon1).abs(); | |
let a = (dlat * 0.5).sin().powi(2) + lat1.cos() * lat2.cos() * (dlon * 0.5).sin().powi(2); | |
2.0 * a.sqrt().asin() | |
} | |
fn differential_distance_on_sphere(lat1: f32, lon1: f32, lat2: f32, lon2: f32) -> [f32; 2] { | |
let diff = 1.0; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
</head> | |
<body> | |
<div id="output"></div> | |
<input type="range" id="kp" min="-1" max="2" value="0" step="0.1" /> | |
<input type="range" id="ki" min="-1" max="2" value="0" step="0.1" /> | |
<input type="range" id="kd" min="-1" max="2" value="0" step="0.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
<body> | |
<canvas id="canvas" width="800" height="800" /> | |
<script> | |
const el = document.getElementById("canvas") | |
const ctx = el.getContext("2d") | |
ctx.lineWidth = 2 | |
function line(x1, y1, x2, y2) { | |
ctx.beginPath() | |
ctx.moveTo(x1, y1) |
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
fn f<'a>(i: &'a mut i32) -> impl FnMut() -> i32 + 'a { | |
move|| {*i = *i + 1; *i} | |
} | |
fn main() { | |
let mut i = 0; | |
{ | |
let mut ff = f(&mut i); | |
dbg!(ff()); | |
dbg!(ff()); |
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
use std::rc::Rc; | |
use std::cell::RefCell; | |
use std::str::Chars; | |
type R<T> = Rc<RefCell<T>>; | |
#[derive(Debug, Clone)] | |
enum V { | |
Symbol(String), | |
Int(i64), |
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
nextto(X, Y, List) :- iright(X, Y, List). | |
nextto(X, Y, List) :- iright(Y, X, List). | |
iright(Left, Right, [Left, Right | _]). | |
iright(Left, Right, [_ | Rest]) :- iright(Left, Right, Rest). | |
zebra(H, W, Z) :- | |
H = [house(norwegian, _, _, _, _), _, house(_, _, _, milk, _), _, _], | |
member(house(englishman, _, _, _, red), H), | |
member(house(spaniard, dog, _, _, _), H), | |
member(house(_, _, _, coffee, green), H), | |
member(house(ukrainian, _, _, tea, _), H), |
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
% 知識 | |
food("中華料理"). | |
food("フランス料理"). | |
food("イタリア料理"). | |
place("新宿"). | |
place("渋谷"). | |
place("池袋"). | |
restaurant("川香苑 本店", "中華料理", "新宿", 3000). |
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
// Basic instructions | |
const NOP = 0; | |
const MOVE = 5; | |
const MOVE_2_1 = 6; | |
const STORE_TO_M0 = 10; | |
const STORE_TO_M1 = 11; | |
const STORE_TO_C1 = 12; | |
const SET_MC1_ROOT = 15; | |
const SET_C1_ROOT = 16; | |
const RESOLVE = 20; |
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
use std::io::Write; | |
use std::process::{Command, Stdio}; | |
fn make_frame(width: usize, height: usize, time: usize) -> Vec<u8> { | |
let mut frame = Vec::with_capacity(4 * width * height); | |
for y in 0..height { | |
for x in 0..width { | |
frame.push((x % 256) as u8); | |
frame.push((y % 256) as u8); | |
frame.push((time % 256) as u8); |
NewerOlder