Skip to content

Instantly share code, notes, and snippets.

View jhorikawa's full-sized avatar

Junichiro Horikawa jhorikawa

View GitHub Profile
@jhorikawa
jhorikawa / planeToPlaneOrientation.h
Created May 15, 2024 06:11
VEX code for plane to plane orientation.
matrix planeToPlaneOrientation(vector upos; vector u1; vector u2; vector vpos; vector v1; vector v2) {
vector u3 = normalize(cross(u1, u2));
vector v3 = normalize(cross(v1, v2));
matrix3 U = set(u1, u2, u3);
matrix3 V = set(v1, v2, v3);
matrix3 rotmat = transpose(U) * V;
matrix mat = ident();
@jhorikawa
jhorikawa / SphereDivide.cs
Created February 28, 2023 09:41
C# code for Grasshopper to divide surface with angle parameter.
private void RunScript(double ang, ref object A)
{
double dang = ang * Math.PI / 180.0;
int div1 = (int) Math.Round(Math.PI / dang);
List<Point3d> points = new List<Point3d>();
for(int i = 0; i < div1; i++){
@jhorikawa
jhorikawa / spiral.lua
Created November 13, 2020 15:09
PICO-8 source code to create animated spiral.
r=64
t=0
function _draw()
cls(1)
for n=0,6,1 do
for i=0,100,1 do
ang=3.1415/180.0*2
x1=cos((i+t)*ang)*i+r
y1=sin((i+t)*ang)*i+r
x2=cos((i+1+t)*ang)*(i+1)+r
@jhorikawa
jhorikawa / circlegrid.lua
Last active November 13, 2020 15:04
PICO-8 source code to create circle grid motion graphics.
r=128
t=0
num=4
rad=9
sp=0.5
function _draw()
cls(13)
val=sin(330/360)
nnum=ceil(num/val)
for i=0,num do
@jhorikawa
jhorikawa / orangepeel.lua
Created November 13, 2020 15:02
PICO-8 source code to create orange peel like motion graphics.
r=64
function _draw()
cls(1)
--print("abc")
num=200.0
rad=50
xss={}
yss={}
sep=3
@jhorikawa
jhorikawa / circletravel.lua
Created November 13, 2020 15:00
PICO-8 source code to create traveling circles using sine wave.
r=64
function _draw()
cls(7)
circfill(r,r,r,0)
num=10
speed=0.3
rad=5
seq=0.5
@jhorikawa
jhorikawa / windmill.lua
Created November 13, 2020 14:57
Source code for PICO-8 to create windmill like motion graphics.
r=64
cr=6
tn=150
d=3
s=0.05
sm=10
trx={}
try={}
for i=1,d do
import random
vals = []
for i in range(7):
vals.append(random.random() * 100)
heap = []
for i in range(len(vals)):
@jhorikawa
jhorikawa / wrapsphere.c
Created April 19, 2020 09:06
Houdini VEX script to wrap sphere with curve.
int res = chi("res");
float rad = chf("rad");
int poly = addprim(0, "polyline");
for(int i=0; i<res; i++){
float ang = $PI * 2 * chf("angmult") * i / (res - 1.0);
float rang = $PI * i / (res - 1.0);
float r = sin(rang) * rad;
float h = cos(rang) * rad;
float x = cos(ang) * r;
float z = sin(ang) * r;
@jhorikawa
jhorikawa / bezierBasisFunc.js
Created April 18, 2020 21:24
Bezier basis function.
function splinePt(points, i, n, t){
let pt1, pt2;
if(n == 1){
pt1 = points[i];
pt2 = points[i+1];
}else{
pt1 = splinePt(points, i, n-1, t);
pt2 = splinePt(points, i+1, n-1, t);
}
let npt = p5.Vector.add(p5.Vector.mult(pt1, (1.0-t)), p5.Vector.mult(pt2, t));