Skip to content

Instantly share code, notes, and snippets.

" 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
AllanHasegawa / gist:60de460618d07c95b97d
Created July 1, 2014 22:35
Latex Beamer Presentation Framework
\documentclass[]{beamer}
% These two lines allows to create PDF with notes
%\usepackage{pgfpages}
%\setbeameroption{show notes on second screen}
\let\Tiny=\tiny
\usetheme{Berlin}
%\usetheme{Copenhagen}
@AllanHasegawa
AllanHasegawa / Makefile
Created August 14, 2014 06:18
openvdb Makefile for Debian testing
# Copyright (c) 2012-2013 DreamWorks Animation LLC
#
# All rights reserved. This software is distributed under the
# Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/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
AllanHasegawa / gist:8ffe63d5e9c973718e22
Last active August 29, 2015 14:05
openvdb "hello world" tests
#include <iostream>
#include <typeinfo>
#include <tuple>
#include <limits>
#include <openvdb/openvdb.h>
typedef openvdb::FloatGrid GridType;
typedef GridType::TreeType TreeType;
@AllanHasegawa
AllanHasegawa / Makefile
Created August 14, 2014 23:20
openvdb "hello world" Makefile
CXX=clang
EXE=ovdb_01
OPENVDB_INCLUDE=/opt/OpenVDB/include
OPENVDB_LIB=/opt/OpenVDB/lib
LIBS=-lm -lstdc++ -ltbb -lHalf -llog4cplus -lopenvdb
@AllanHasegawa
AllanHasegawa / gist:9d73beda100a360b3008
Last active August 29, 2015 14:05
Amanatides DDA Traversal Implemented in Python
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
AllanHasegawa / gist:7543a22b0e5b57d9ab9f
Created August 29, 2014 20:08
Overloading Grid::FloatGrid with Z-Curve Order for elements of the LeafNode
#ifdef OPENVDB_USE_ZORDER
namespace openvdb {
namespace v3_0_0 {
namespace tree {
inline uint32_t splitBy3(uint32_t x)
{
return (x & 0x1) | ((x & 0x2) << 2) | ((x & 0x4) << 4);
}
template<>
@AllanHasegawa
AllanHasegawa / gist:532b83b6a84350402e64
Last active August 29, 2015 14:06
OpenVDB - create_levelset_volume
// 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_STATIC_ASSERT(
boost::is_floating_point<typename GridType::ValueType>::value);
@AllanHasegawa
AllanHasegawa / gist:db1752da2f982ea0dfb2
Last active August 29, 2015 14:06
OpenVDB - create_levelset_volume (usage)
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
AllanHasegawa / gist:310b526568b7157faad4
Created October 7, 2014 06:26
Cylinder Line Minimum Distance plot
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