Skip to content

Instantly share code, notes, and snippets.

View jrzingel's full-sized avatar

James Zingel jrzingel

  • New Zealand
View GitHub Profile
@jrzingel
jrzingel / hilbert.py
Last active January 30, 2025 07:50
Pseudo (generalised?) hilbert curve generator. Maps ordered items from a list to a 2D array. Importantly it works for any specified size, not just powers of two or even numbers
# Pseudo-hilbert curve generator. Maps ordered items from an array (1D) to a rectangle (2D)
# in a way that best retains the distances between indexes of the initial array as euclidean distances in the rectangle
#
# Hilbert curves are only possible for powers of 2, so the gilbert() function instead tries to fit as many hilbert
# "blocks" together as possible. This is through a greedy approach and works well enough for my needs
#
# Free for any use, but let me know so I know someone found it useful :)
#
# AUTHOR : James Zingel (2022)
@jrzingel
jrzingel / directionalcoupler.tex
Created October 2, 2024 01:24
Directional coupler for circuitikz
\documentclass [tikz,border=10pt]{standalone}
\usepackage{circuitikz}
\begin{document}
\newcommand{\dircoupler}[2]{ % #1 = name of object, #2 = rotation angle
\draw[thick,rotate=#2] (#1.nw) -- (#1.ne) -- (#1.se) -- (#1.sw) -- cycle;
\draw[thick,rotate=#2] (#1.n) -- ++(.3,0) -- ++(0,-0.3);
\draw[thick,rotate=#2] (#1.e) -- (#1.w);
}