Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Keisuke OTAKI cocomoff

🏠
Working from home
Block or report user

Report or block cocomoff

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View line_segment_intersect.py
def line_segment_intersection(p1, p2, p3, p4):
d = (p2[0] - p1[0]) * (p4[1] - p3[1]) - (p2[1] - p1[1]) * (p4[0] - p3[0])
if d == 0.0:
return None
intersect = [0.0, 0.0]
u = ((p3[0] - p1[0]) * (p4[1] - p3[1]) - (p3[1] - p1[1]) * (p4[0] - p3[0])) / d
v = ((p3[0] - p1[0]) * (p2[1] - p1[1]) - (p3[1] - p1[1]) * (p2[0] - p1[0])) / d
if u < 0.0 or u > 1.0 or v < 0.0 or v > 1.0:
return None
View dFrechet.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cocomoff
cocomoff / edge.txt
Created Dec 3, 2019
Plots in Julia for graph visualizer (tentative)
View edge.txt
1 2
1 3
2 4
3 4
3 5
4 5
@cocomoff
cocomoff / public.rs
Created Sep 24, 2019
tekitou public
View public.rs
use fast_paths::InputGraph;
use fast_paths::PreparationGraph;
use fast_paths::Dijkstra;
use fast_paths::contract_node;
fn main() {
let mut input_graph = InputGraph::new();
// // 01234=ABCDE
// input_graph.add_edge_bidir(0, 2, 1);
// input_graph.add_edge_bidir(1, 2, 4);
@cocomoff
cocomoff / public.rs
Created Sep 24, 2019
tekitou public
View public.rs
use fast_paths::InputGraph;
use fast_paths::PreparationGraph;
use fast_paths::Dijkstra;
use fast_paths::contract_node;
fn main() {
let mut input_graph = InputGraph::new();
// // 01234=ABCDE
// input_graph.add_edge_bidir(0, 2, 1);
// input_graph.add_edge_bidir(1, 2, 4);
@cocomoff
cocomoff / index.html
Created Aug 26, 2019
bokeh example (index template)
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Flask Bokeh Sample</title>
{% autoescape False %}
{{ resources }}
{% endautoescape %}
</head>
<body>
View bokeh_example.py
# -*- coding: utf-8 -*-
import json
from bokeh.embed import json_item
from bokeh.plotting import figure
from bokeh.resources import CDN
from bokeh.sampledata.iris import flowers
from bokeh.embed import components
from bokeh.plotting import figure
from flask import Flask, render_template
@cocomoff
cocomoff / example_legendre.jl
Created Aug 15, 2019
Legendre変換のお勉強: (x, y)ではなく(p, w)で関数を表す
View example_legendre.jl
using Plots
# 適当な2次関数,導関数,接線の方程式
f(x; b=-3, d=2) = (b .+ x) .^2 .+ d
df(x; b=-3, d=2) = 2 .* (b .+ x)
fₜₐₙ(x, xₚ; b=-3, d=2) = df(xₚ) .* (x .- xₚ) .+ f(xₚ, b=b, d=d)
# 関数
x = 1:0.1:5;
View random_road_network.py
# -*- coding: utf-8 -*-
#
# build random road network
#
# 1. randomly sample location points
# 2. compute pair-wise shortest paths
# 3. keep pairs if its length < 1.5 x (ST)
import numpy as np
import networkx as nx
View dp_zdd.cpp
#include <bits/stdc++.h>
#include "cuddObj.hh"
using namespace std;
const string red = "\033[0;31m";
const string green = "\033[0;32m";
const string reset = "\033[0m";
// Global manager
Cudd mgr;
You can’t perform that action at this time.