Skip to content

Instantly share code, notes, and snippets.

@stla
stla / .gitignore
Last active May 20, 2022
Solid Möbius strip with POV-Ray
View .gitignore
*.png
*.ini
@stla
stla / hdelaunay.cpp
Last active May 20, 2022
hyperbolic delaunay
View hdelaunay.cpp
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Triangulation_data_structure_2.h>
#include <CGAL/Hyperbolic_Delaunay_triangulation_2.h>
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
#include <CGAL/Triangulation_vertex_base_with_id_2.h>
#include <CGAL/number_utils.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Exact_predicates_exact_constructions_kernel EK;
@stla
stla / H4_600-cell.R
Last active Mar 16, 2022
H4 projection of the 600-cell polytope
View H4_600-cell.R
# https://vixra.org/pdf/1411.0130v1.pdf
# vertices of the 600-cell
phi <- (1+sqrt(5))/2
vs <- rbind(
c( -1.0 , -1.0 , -1.0 , -1.0 )
, c( -1.0 , -1.0 , -1.0 , 1.0 )
, c( -1.0 , -1.0 , 1.0 , -1.0 )
, c( -1.0 , -1.0 , 1.0 , 1.0 )
, c( -1.0 , 1.0 , -1.0 , -1.0 )
@stla
stla / E8_Coxeter.R
Last active Mar 15, 2022
E8 in Coxeter plane
View E8_Coxeter.R
# https://github.com/SuperJason/python/blob/96989d1681085a87a0d7f488d926a1677cd7041f/famous_math_graphics/e8.py
# Roots of the form (+-1, +-1, 0, 0, 0, 0, 0, 0),
# signs can be chosen independently and the two non-zeros can be anywhere.
library(arrangements)
combs <- combinations(8L, 2L)
vs11 <- NULL
for(i in 1L:nrow(combs)){
comb <- combs[i, ]
for(x in c(-2, 2)){
@stla
stla / E8_Petrie.gif
Last active Mar 13, 2022
E8 in E6 Petrie projection
@stla
stla / griddip.R
Last active Feb 28, 2022
Griddip (truncated icosidodecahedron) with rgl (R)
View griddip.R
library(cxhull)
library(rgl)
rotation4Dplane <- function(axis1, axis2, theta, vector){
# axes must be normalized
vx <- sum(vector*axis1)
vy <- sum(vector*axis2)
cos_theta <- cos(theta)
sin_theta <- sin(theta)
coef1 <- vx*cos_theta - vy*sin_theta
@stla
stla / HopfTorusMovingColors.asy
Last active Feb 16, 2022
Hopf torus with moving colors using Asymptote
View HopfTorusMovingColors.asy
settings.render = 4;
settings.outformat = "eps";
size(500,0);
import graph3;
import palette;
currentlight = light(gray(0.85), ambient=black, specularfactor=13,
(0.5,0.5,1), specular=white, viewport=false);
// files to create
@stla
stla / .gitignore
Last active Jan 29, 2022
Hopf torus with dynamic color
@stla
stla / pht.R
Created Jan 27, 2022
pseudo hopf
View pht.R
setwd("U:/Data/Rstuff/rgl/Hopf2")
# https://mathmod.deviantart.com/art/Pseudo-Hopf-Tori-565531249
library(misc3d)
library(rgl)
cu <- cv <- 0.0000000001
N <- 3
Fx <- function(u,v){ -cos(u+v)/(sqrt(2)+cos(v-u)) }
DFx <- function(u,v){
DFxu = (Fx(u,v)-Fx(u+cu,v))/cu
@stla
stla / SolidMobiusStrip_to_Torus.R
Created Jan 17, 2022
Solid Möbius strip to torus
View SolidMobiusStrip_to_Torus.R
library(misc3d)
library(rgl)
library(spray)
f <- function(x, y, z, a, b){
((x*x+y*y+1)*(a*x*x+b*y*y)+z*z*(b*x*x+a*y*y)-2*(a-b)*x*y*z-a*b*(x*x+y*y))^2 -
4*(x*x+y*y)*(a*x*x+b*y*y-x*y*z*(a-b))^2
}
gradient <- function(xyz){