Skip to content

Instantly share code, notes, and snippets.

View ialhashim's full-sized avatar

Ibraheem Alhashim ialhashim

View GitHub Profile
@ialhashim
ialhashim / gist:f99ffdfaa60caeafc070
Created August 27, 2015 20:27
Get JSON format 3D model
Query:
https://3dwarehouse.sketchup.com/search.html?q=chair
Extract subjectIDs
Then:
https://3dwarehouse.sketchup.com/warehouse/getbinary?subjectId=XXXXXXXX&subjectClass=entity&cache=1440704568191&name=skj
@ialhashim
ialhashim / bluenoise.h
Last active August 29, 2015 13:55
N-dimensional blue-noise sampling
// From Robert Bridson's curlnoise
// Example usage:
// std::vector<Vector3> samples;
// bluenoise_sample<3, double, Vector3>(0.02, Vector3(-0.5,-0.5,-0.5), Vector3(0.5,0.5,0.5), samples );
//
#ifndef BLUENOISE_H
#define BLUENOISE_H
#include <array>
// Code from igl library
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla Public License
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
// obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include <Eigen/Geometry>
#include <Eigen/Dense>
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
@ialhashim
ialhashim / number_check.hpp
Created July 27, 2014 21:10
Fix Visual Studio Lack of isnan and isfinite (C++)
// 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();
}
}
@ialhashim
ialhashim / sphere_fibonacci_points.cpp
Created July 27, 2014 21:11
Computes sphere points on a Fibonacci spiral
// 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 )
@ialhashim
ialhashim / geometric_median.cpp
Created July 27, 2014 21:12
Geometric median and geometric centroid
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;
@ialhashim
ialhashim / proximity.cpp
Created September 29, 2014 21:32
Compute proximity of triangle-triangle in 3D
// 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;
@ialhashim
ialhashim / 2DNearIsometricDeformations.pro
Created November 7, 2014 22:15
2D Near Isometric Deformations - modern qmake pro file.
# 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
@ialhashim
ialhashim / fixVS.vs1
Last active August 29, 2015 14:09
Fixing Microsoft Visual Studio 2013 and Qt x64
# 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
}