Skip to content

Instantly share code, notes, and snippets.

View Mathias-Fuchs's full-sized avatar
🗺️

Mathias Fuchs Mathias-Fuchs

🗺️
View GitHub Profile
@Mathias-Fuchs
Mathias-Fuchs / main.c
Created October 29, 2021 09:21
Round the corners of a png
#define _CRT_SECURE_NO_WARNINGS
#define STB_IMAGE_IMPLEMENTATION
#include "../stb/stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "../stb/stb_image_write.h"
int main(int argc, char** argv)
{
char* filename[6];
@Mathias-Fuchs
Mathias-Fuchs / exporter.cpp
Created October 13, 2021 18:28
the worker function that exports a Rhino mesh to INRIA mesh/meshb format, using the libmeshb7.h header
BOOL CMeshbExporterPlugIn::savemeshtomeshormeshb(const ON_Mesh& m, const wchar_t* filename) {
{
if (m.VertexCount() == 0) {
RhinoApp().Print("This mesh seems to be empty.");
return FALSE;
}
ON_Mesh* mdp = m.Duplicate();
if (!mdp) {
@Mathias-Fuchs
Mathias-Fuchs / Makefile
Created June 12, 2020 10:10
simple makefile for mmg test and example programs
CC = gcc
CPP = g++
INCL = -I$(HOME)/mmg/buildLinuxDebug/include/
CFLAGS += -g -Wall -Wextra -pedantic -fPIC `pkg-config --cflags cairo` -DWITHCAIRO -D_DEBUG -DEXTRADEBUG
CPPFLAGS += -g -Wall -Wextra -pedantic -fPIC `pkg-config --cflags cairo` -DWITHCAIRO -D_DEBUG -DEXTRADEBUG --std=c++17
LDFLAGS += -L$(HOME)/mmg/buildLinuxDebug/lib/ -Wl,-rpath=$(HOME)/mmg/buildLinuxDebug/lib -lmmg -lcairo -lm
main.o: main.c
$(CC) $(CFLAGS) $(INCL) -c -o $@ $<
@Mathias-Fuchs
Mathias-Fuchs / main.c
Last active June 3, 2020 08:56
Meshing with anisotropic metric in MMG2D without a msh/sol file
#include <stdio.h>
#include <stdlib.h>
#include <mmg/mmg2d/libmmg2d.h>
#include <math.h>
int main() {
MMG5_pMesh mesh2 = NULL;
MMG5_pSol met2 = NULL;
int ier = 0;
MMG2D_Init_mesh(MMG5_ARG_start, MMG5_ARG_ppMesh, &mesh2, MMG5_ARG_ppMet, &met2, MMG5_ARG_end);
@Mathias-Fuchs
Mathias-Fuchs / cobweb.cs
Last active February 11, 2020 08:40
Clean cobwesh meshes in three js and Rhino C#.
Mesh M = new Mesh();
int axis_divisions = 100;
int height_divisions = 200;
M.Vertices.Capacity = axis_divisions * height_divisions;
M.Faces.Capacity = 2 * (axis_divisions * (height_divisions - 1));
for (int th = 0; th < axis_divisions; th++)
{
double x = Math.Cos(2.0 * Math.PI * th / (double) axis_divisions);
@Mathias-Fuchs
Mathias-Fuchs / Homology.cs
Created December 10, 2019 18:28
some code quarry for homology computation
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MathNet.Numerics;
using System.Numerics;
@Mathias-Fuchs
Mathias-Fuchs / estSquareOfMean.R
Last active February 23, 2019 18:56
Estimating the square of the mean, see www.mathiasfuchs.de/b2.html for the diary entry.
# our sample size
n <- 10
# generate all subsets of size 2
co <- combn(n, 2)
# confirm that the false friend is biased by generating a lot of samples
f <- rep(0, 50000)
g <- rep(0, 50000)
@Mathias-Fuchs
Mathias-Fuchs / tutte.js
Last active February 11, 2019 15:14
Deforming a random Delaunay triangulation into its Tutte embedding
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 300;
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor( 0xffffff, 1 );
document.body.appendChild(renderer.domElement);
var material = new THREE.MeshBasicMaterial({
color: "white",
@Mathias-Fuchs
Mathias-Fuchs / main.R
Last active September 25, 2018 11:28
testing some distance computations
require(igraph)
require(RColorBrewer)
require(rgl)
G <- make_lattice(length=10, dim=2)
r <- c()
for (i in 4:6) r <- c(r, (4:6) + 10 * i)
G <- delete_vertices(G, r)
n <- length(V(G))
u0 <- rep(0, n)
u0[1] <- 1
@Mathias-Fuchs
Mathias-Fuchs / .gitignore
Last active August 19, 2018 08:50
a snippet of R code showing the convergence of a Fourier series against a sum of Dirac measures. The spatstat package is only used for visualisation
*~
.Rhistory
Rplot*.*