Skip to content

Instantly share code, notes, and snippets.


Allan Hasegawa AllanHasegawa

View GitHub Profile
View gist:34cd40766d01b2504d12
" Space is your leader
let mapleader = "\<Space>"
" My <leader> mappings
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>
vmap <leader>y "+y
vmap <leader>d "+d
nmap <leader>p "+p
nmap <leader>P "+P
AllanHasegawa / gist:60de460618d07c95b97d
Created Jul 1, 2014
Latex Beamer Presentation Framework
View gist:60de460618d07c95b97d
% These two lines allows to create PDF with notes
%\setbeameroption{show notes on second screen}
AllanHasegawa / Makefile
Created Aug 14, 2014
openvdb Makefile for Debian testing
View Makefile
# Copyright (c) 2012-2013 DreamWorks Animation LLC
# All rights reserved. This software is distributed under the
# Mozilla Public License 2.0 ( )
# Redistributions of source code must retain the above copyright
# and license notice and the following restrictions and disclaimer.
# * Neither the name of DreamWorks Animation nor the names of
# its contributors may be used to endorse or promote products derived
AllanHasegawa / gist:9d73beda100a360b3008
Last active Aug 29, 2015
Amanatides DDA Traversal Implemented in Python
View gist:9d73beda100a360b3008
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.path import Path
import matplotlib.patches as patches
pylab.rcParams['figure.figsize'] = (10.0, 10.0)
class Ray:
def __init__(self):
self.origin = np.zeros((2))
AllanHasegawa / gist:8ffe63d5e9c973718e22
Last active Aug 29, 2015
openvdb "hello world" tests
View gist:8ffe63d5e9c973718e22
#include <iostream>
#include <typeinfo>
#include <tuple>
#include <limits>
#include <openvdb/openvdb.h>
typedef openvdb::FloatGrid GridType;
typedef GridType::TreeType TreeType;
AllanHasegawa / Makefile
Created Aug 14, 2014
openvdb "hello world" Makefile
View Makefile
LIBS=-lm -lstdc++ -ltbb -lHalf -llog4cplus -lopenvdb
AllanHasegawa / gist:7543a22b0e5b57d9ab9f
Created Aug 29, 2014
Overloading Grid::FloatGrid with Z-Curve Order for elements of the LeafNode
View gist:7543a22b0e5b57d9ab9f
namespace openvdb {
namespace v3_0_0 {
namespace tree {
inline uint32_t splitBy3(uint32_t x)
return (x & 0x1) | ((x & 0x2) << 2) | ((x & 0x4) << 4);
AllanHasegawa / gist:532b83b6a84350402e64
Last active Aug 29, 2015
OpenVDB - create_levelset_volume
View gist:532b83b6a84350402e64
// V type must provide "V::aabb()" and "V::distance(const glm::vec3&)" methods
template <typename GridType, typename V>
typename GridType::Ptr
create_levelset_volume(const V& kVolume, const float kVoxelSize,
const float kHalfWidth)
using ValueType = typename GridType::ValueType;
// GridType::ValueType is required to be a floating-point scalar.
boost::is_floating_point<typename GridType::ValueType>::value);
AllanHasegawa / gist:db1752da2f982ea0dfb2
Last active Aug 29, 2015
OpenVDB - create_levelset_volume (usage)
View gist:db1752da2f982ea0dfb2
using GridT = openvdb::FloatGrid;
auto grid1 = openvdb::tools::createLevelSetSphere<GridT>(
512.0, openvdb::Vec3f(0, 0, 0), 1, 2);
Sphere s0{glm::vec4(-512,-512,512,1), 16};
LinearSphereSweptVolume volume0(s0, /*translation=*/glm::vec3(1024, 1024, 0));
auto grid2 = create_levelset_volume<GridT>(volume0, 1, 2);
openvdb::tools::csgDifference(*grid1, *grid2);
s0 = Sphere{glm::vec4(-512,512,1024,1), 16};
AllanHasegawa / gist:310b526568b7157faad4
Created Oct 7, 2014
Cylinder Line Minimum Distance plot
View gist:310b526568b7157faad4
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
import scipy as sp
import scipy.optimize
def cylinderLineFirstInterval(cylinderLength, lineP0, lineP1):
l = cylinderLength
p0 = lineP0
p1 = lineP1
You can’t perform that action at this time.