Skip to content

Instantly share code, notes, and snippets.

@thehans
thehans / sorted compile words
Created February 6, 2019 07:06
compare cmake vs qmake
-c
CMakeFiles/OpenSCAD.dir/src/export_amf.cc.o
-DEIGEN_DONT_ALIGN
-DENABLE_CGAL
-DENABLE_EXPERIMENTAL
-DENABLE_LIB3MF
-DENABLE_LIBZIP
-DENABLE_OPENCSG
-D__GCC
-DNDEBUG
@thehans
thehans / command line log
Created February 10, 2019 19:00
Attempt to build latest Eigen 3.3.7
root@f12677981478:/mxe# make update-package-eigen && \
> make JOBS=6 -j8 \
> MXE_PLUGIN_DIRS=plugins/gcc7 \
> MXE_TARGETS=x86_64-w64-mingw32.static.posix \
> eigen
NEW eigen 3.2.5 --> 3.3.7
sed -i 's/^\([^ ]*_VERSION *:=\).*/\1 3.3.7/' '/mxe/src/eigen.mk'
make -f 'Makefile' 'update-checksum-eigen' || { sed -i 's/^\([^ ]*_VERSION *:=\).*/\1 3.2.5/' '/mxe/src/eigen.mk'; exit 1; }
make[1]: Entering directory '/mxe'
mkdir -p '/mxe/pkg' && ( (wget --user-agent='Wget/1.18' -T 30 -t 3 -O '/mxe/pkg/.tmp-eigen-3.3.7.tar.bz2' 'https://bitbucket.org/eigen/eigen/get/3.3.7.tar.bz2' && true) ) && cat '/mxe/pkg/.tmp-eigen-3.3.7.tar.bz2' > '/mxe/pkg/eigen-3.3.7.tar.bz2' && rm '/mxe/pkg/.tmp-eigen-3.3.7.tar.bz2' || ( echo; echo 'Download failed!'; echo; rm -f '/mxe/pkg/eigen-3.3.7.tar.bz2' '/mxe/pkg/.tmp-eigen-3.3.7.tar.bz2'; ) && sed -i 's/^\([^ ]*_CHECKSUM *:=\).*/\1 '"`openssl dgst -sha256 '/mxe/pkg/eigen-3.3.7.tar.bz2' 2>/dev/null | sed -n 's,^.*\([0-9a-f]\{64\}\)$,\1,p'`"'/' '/mxe/src/eigen.mk'
@thehans
thehans / testcase.i
Created February 13, 2019 06:14
gcc bug
class A { private: friend int &operator<<(int &i, const A &value) { return i; } };
#pragma GCC optimize ("-fno-ipa-cp-clone")
class B { };
int &operator<<(int &i, const B &ast);
@thehans
thehans / surface.dat
Created February 15, 2019 19:44
remove z=0 from surface
#surface.dat
10 9 8 7 6 5 5 5 5 5
9 8 7 6 6 4 3 2 1 0
8 7 6 6 4 3 2 1 0 0
7 6 6 4 3 2 1 0 0 0
6 6 4 3 2 1 1 0 0 0
6 6 3 2 1 1 1 0 0 0
6 6 2 1 1 1 1 0 0 0
6 6 1 0 0 0 0 0 0 0
3 1 0 0 0 0 0 0 0 0
@thehans
thehans / BezierHans.scad
Created March 14, 2019 22:57
Bezier curve function for OpenSCAD (any order curve, any dimension points)
BezierExample();
//BezierCircleApprox(10);
// cubic bezier circle approximation example
module BezierCircleApprox(r) {
$fn=1000;
c = 0.551915024494;
points = BezierPath([
@thehans
thehans / filter_fermat2k.c
Created May 18, 2019 20:41
Test of alternative powm specific to base-2 fermat test, using Left to right k-ary exponentiation.
#include <gmp.h>
#include <stdio.h>
#include <stdlib.h>
#include "../gmp-6.1.2/gmp-impl.h"
#include "../gmp-6.1.2/longlong.h"
static inline mp_limb_t
getbits (const mp_ptr p, mp_bitcnt_t bi, int nbits)
{
int nbits_in_r;
@thehans
thehans / segmented_bit_sieve.cpp
Last active August 29, 2019 15:34
POC "PunchWheel" tweak to Kim Walisch's Segmented Sieve example. (First revision is Kim's unedited for comparison)
/// @file segmented_bit_sieve.cpp
/// @author Kim Walisch, <kim.walisch@gmail.com>
/// @brief This is an implementation of the segmented sieve of
/// Eratosthenes which uses a bit array with 16 numbers per
/// byte. It generates the primes below 10^10 in 7.25 seconds
/// on an Intel Core i7-6700 3.4 GHz CPU.
/// @license Public domain.
#include <iostream>
#include <algorithm>
@thehans
thehans / rotate_extrude2.scad
Created November 5, 2019 21:49
Backwards compatible rotate_extrude for OpenSCAD with angle parameter
// older versions of OpenSCAD do not support "angle" parameter for rotate_extrude
// this module provides that capability even when using older versions (such as thingiverse customizer)
module rotate_extrude2(angle = 360, convexity = 2, size = 1000) {
module angle_cut(angle = 90, size = 1000) {
x = size*cos((angle / 2));
y = size*sin((angle / 2));
translate([0, 0, -size]) linear_extrude((2 * size)) polygon([[0, 0], [x, y], [x, size], [-size, size], [-size, -size], [x, -size], [x, -y]]);
}
// support for angle parameter in rotate_extrude was added after release 2015.03
// Thingiverse customizer is still on 2015.03
@thehans
thehans / perf.scad
Created November 6, 2019 20:15
Performance test of complex object unioned with many simple objects
$fn = 100;
module rounded_cube(size,r,center=false)
{
s = is_list(size) ? size : [size,size,size];
translate(center ? -s/2 : [0,0,0])
hull() {
translate([ r, r, r]) sphere(r=r);
translate([ r, r,s.z-r]) sphere(r=r);
translate([ r,s.y-r, r]) sphere(r=r);
@thehans
thehans / duct.scad
Created November 18, 2019 18:39
Basic duct transition using hull in OpenSCAD
fan=120;
ductl=110;
ductw=40;
h=150;
wallTh = 2;
module transition(h,l1,w1,l2,w2,eps=0.01) {
hull() {
cube([l1,w1,eps], center=true);
translate([0,0,h-eps]) cube([w2,l2,eps], center=true);