This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import sample | |
from string import digits, ascii_uppercase, ascii_lowercase | |
from tempfile import gettempdir | |
from os import path | |
def rand_fname(suffix='', length=8): | |
chars = ascii_lowercase + ascii_uppercase + digits | |
#fname = path.join(gettempdir(), 'tmp-' + ''.join(sample(chars, length)) + suffix) | |
fname = 'tmp-' + ''.join(sample(chars, length)) + suffix | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
// Code adapted from https://github.com/propanoid/DBSCAN | |
#include <vector> | |
#include <algorithm> | |
#include <omp.h> | |
// Any basic vector/matrix library should also work | |
#include <Eigen/Core> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fix Visual Studio | |
#ifdef WIN32 | |
namespace std{ | |
template<typename T> bool isnan(T x){ return _isnan(x); } | |
template<typename T> bool isfinite(T arg){ | |
return arg == arg && | |
arg != std::numeric_limits<T>::infinity() && | |
arg != -std::numeric_limits<T>::infinity(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPHERE_FIBONACCI_POINTS computes sphere points on a Fibonacci spiral. | |
// | |
// John Burkardt - 21 October 2013 / This code is distributed under the GNU LGPL license. | |
// | |
// Reference: | |
// | |
// Richard Swinbank, James Purser, | |
// Fibonacci grids: A novel approach to global modelling. July 2006 | |
// | |
inline std::vector< Vector3Type > sphere_fibonacci_points ( int n = 100 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline QVector<QColor> rndColors(int count){ | |
QVector<QColor> colors; | |
float currentHue = 0.0; | |
for (int i = 0; i < count; i++){ | |
colors.push_back( QColor::fromHslF(currentHue, 1.0, 0.5) ); | |
currentHue += 0.618033988749895f; | |
currentHue = std::fmod(currentHue, 1.0f); | |
} | |
return colors; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename Vector, typename Container> | |
Vector geometric_median( const Container& data, int iterations = 200 ) | |
{ | |
size_t N = data.size(); | |
if(N < 3) return data.front(); | |
size_t dim = data.front().size(); | |
std::vector<Vector> A (2, (data[0] + data[1]) / Scalar(2)); | |
for(int it = 0; it < iterations; it++){ | |
Vector numerator; for(size_t i = 0; i < dim; i++) numerator[i] = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename Scalar, typename Container> | |
inline static Eigen::Matrix<Scalar,-1,-1> toEigenMatrix( const Container& vectors ){ | |
typedef typename Container::value_type VectorType; | |
typedef typename VectorType::value_type Scalar; | |
Eigen::Matrix<Scalar,-1,-1> M(vectors.size(), vectors.front().size()); | |
for(size_t i = 0; i < vectors.size(); i++) | |
for(size_t j = 0; j < vectors.front().size(); j++) | |
M(i,j) = vectors[i][j]; | |
return M; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adapted from: https://github.com/flexible-collision-library/fcl | |
#include <Eigen/Geometry> | |
namespace Intersect{ | |
typedef double Scalar; | |
typedef Eigen::Vector3d Vector3; | |
const Scalar EPSILON = 1e-5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 2D Near Isometric Deformations - | |
# code from : http://www.cs.technion.ac.il/~cggc/Upload/Projects/KVFDeformation/index.html | |
QT += core gui opengl | |
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | |
TEMPLATE = app | |
TARGET = KVF_deform | |
INCLUDEPATH += . ./include |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install NuGet to run inside VS | |
# Get VC project files | |
$include = @("*.vcxproj","*.sln") | |
$projectFiles = gci . -recurse -force -include $include | |
foreach ($file in $projectFiles) { | |
(get-content $file) | % { $_ -creplace 'Win32', 'x64' } | set-content $file | |
(get-content $file) | % { $_ -creplace '%40QMAKE_SUBSYSTEM_SUFFIX%40', '' } | set-content $file | |
} |