Skip to content

Instantly share code, notes, and snippets.

@stla
stla / integrate_polynomial_on_simplex.jl
Created Dec 2, 2022
Exact integral of a polynomial over a simplex, with Julia
View integrate_polynomial_on_simplex.jl
using TypedPolynomials
using LinearAlgebra
function integratePolynomialOnSimplex(P, S)
gens = variables(P)
n = length(gens)
v = S[end]
B = Array{Float64}(undef, n, 0)
for i in 1:n
B = hcat(B, S[i] - v)
@stla
stla / integral_on_simplex.py
Last active Dec 1, 2022
Exact integral of a polynomial over a tetrahedron or a simplex, with Python.
View integral_on_simplex.py
from math import factorial
from sympy import Poly
import numpy as np
def term(Q, monom):
coef = Q.coeff_monomial(monom)
powers = list(monom)
j = sum(powers)
if j == 0:
return coef
@stla
stla / septuaginta.off
Created Oct 25, 2022
Mesh of Leonardo da Vinci's 72-sided sphere (Campanus' sphere, septuaginta)
View septuaginta.off
OFF
62 72 0
0.866025403784439 0.5 0
0.5 0.866025403784439 0
0 1 0
-0.5 0.866025403784439 0
-0.866025403784439 0.5 0
-1 0 0
-0.866025403784439 -0.5 0
@stla
stla / greatStellatedDodecahedron.off
Created Oct 24, 2022
Mesh of a true great stellated dodecahedron with triangular faces only and without self-intersection.
View greatStellatedDodecahedron.off
OFF
32 60 0
-0.9341723 -1.618034 -2.088873
-0.5773503 -1 -0.2205282
-0.7136442 0 -0.9341724
-1.868345 0 2.088873
-0.3568221 0.618034 0.9341724
-1.154701 0 0.2205282
-2.088873 1.618034 0.9341723
@stla
stla / greatStellatedDodecahedron.off
Created Oct 22, 2022
Great stellated dodecahedron.
View greatStellatedDodecahedron.off
OFF
32 60 0
0 0 2.8025170768881473
1.8683447179254316 0 -2.0888728973419672
-0.93417235896271578 1.6180339887498949 -2.0888728973419672
-0.93417235896271578 -1.6180339887498949 -2.0888728973419672
-2.0888728973419672 1.6180339887498949 0.93417235896271578
-2.0888728973419672 -1.6180339887498949 0.93417235896271578
-0.35682208977308993 -2.6180339887498949 0.93417235896271578
@stla
stla / list2list.R
Last active Aug 6, 2022
Python utils in R
View list2list.R
setwd("C:/SL/Python/RPythonUtils")
library(clipr)
list2list <- function(L, outfile = "list.txt") {
singletons_idxs <- which(lapply(L, length) == 1)
singletons <- L[singletons_idxs]
L <- replace(L, singletons_idxs, sprintf("c(%s)", singletons))
write_clip(L, breaks = "],\n", sep = ", ")
cat("[",
@stla
stla / griddip.gif
Last active Jul 20, 2022
4D polytopes with POV-Ray
@stla
stla / HelicoCateno.gif
Last active Jul 19, 2022
Miscellaneous 3D stuff with 'rgl' (R).
@stla
stla / .gitignore
Last active Sep 24, 2022
Higher-dimensional stuff with 'rgl' (R)
View .gitignore
zzpic*
.Rproj.user
*.Rproj
@stla
stla / .gitignore
Last active Jul 18, 2022
Cyclides and pseudo-cyclides with 'rgl' (R)