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 linreg::{linear_regression, Error}; | |
use num::Float; | |
use std::env; | |
fn fractal_dim(path: String) { | |
let img = image::open(path).unwrap(); | |
let img = img.to_rgb8(); | |
let width: f32 = img.width() as f32; | |
let height: f32 = img.height() as f32; |
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
let W = 1200; | |
let H = 1200; | |
function setup() { | |
createCanvas(W, H); | |
background(255); | |
smooth(); | |
noLoop(); | |
noStroke(); | |
pixelDensity(12); | |
} |
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 rug::{ops::Pow, Assign, Integer}; | |
fn fermat_test(target: u32, base: u32) -> bool { | |
let n = target; | |
let mut a = Integer::new(); | |
a.assign(base); | |
// 合成数であることを正とする | |
if a.pow(n - 1) % 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
use rug::{ops::Pow, Integer}; | |
struct PrimeNumber { | |
num: Integer, | |
is_prime: bool, | |
} | |
fn lucas_lehmer_test(p: u32) -> PrimeNumber { | |
// Mercenne Number : (2^p - 1) | |
let mersenne_number = |v| (Integer::from(1) << v) - 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
// ref: とほほのRust入門(https://www.tohoho-web.com/ex/rust.html) | |
use rand::Rng; | |
use std::boxed::Box; | |
use std::collections::HashMap; | |
// enum Color { | |
// Red, | |
// Green, | |
// Blue, | |
// } |
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
uniform vec2 resolution; | |
uniform float time; | |
uniform float width; | |
uniform float scale; | |
uniform float align; | |
out vec4 fragColor; | |
#define EPS 1E-4 |
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
# Orthographic projection | |
eps = 0.000001 | |
def onSetupParameters(scriptOp): | |
params = scriptOp.appendCustomPage('Parameters') | |
params.appendFloat('Ratio', label='Aspect Ratio') | |
params.appendFloat('Size', label='Orthographic Size') | |
params.appendFloat('N', label='Near') | |
params.appendFloat('F', label='Far') |
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
# Perspective Projection | |
eps = 0.000001 | |
def onSetupParameters(scriptOp): | |
params = scriptOp.appendCustomPage('Parameters') | |
params.appendFloat('Size', label='Perspective Size') | |
params.appendFloat('Ratio', label='Aspect Ratio') | |
params.appendFloat('N', label='Near') | |
params.appendFloat('F', label='Far') |
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
# Reverse Perspective projection | |
eps = 0.000001 | |
def onSetupParameters(scriptOp): | |
params = scriptOp.appendCustomPage('Parameters') | |
params.appendFloat('Perspective', label='Perspective') | |
params.appendFloat('Distance', label='Distance') | |
params.appendFloat('Ratio', label='Aspect Ratio') | |
params.appendFloat('Size', label='Orthographic Size') |
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
import nfc | |
import binascii | |
from pythonosc.udp_client import SimpleUDPClient | |
from pythonosc.osc_message_builder import OscMessageBuilder | |
# PC<->Raspberry Pi LAN (IP Address) | |
IP = "XXX.XXX.XXX.XXX" | |
PORT = 8400 | |
client = SimpleUDPClient(IP, PORT) |