Output Spectrum Data From MP3 to TXT Using BASS Library 2012-11-25

In order to make the fountain video I needed to take an mp3 file and get its spectrum data to an ascii file. This data would then be used as the input to the simulation.

The code below will take an “INPUT.mp3” and output to “OUTPUT.txt” the rate at which the data is collected (fps) can be controlled along with the resolution of the data (BANDS).

The code was written using the writewav.c and spectrum.c examples in the BASS sdk. The library is free for non-commercial use and is availible for Windows, Mac OS, Linux, Win64, WinCE, iOS, Android, and ARM

Generating Hexagonally Close-Packed Spheres 2012-11-25

This C++ code snippit will generate a hexagonally close-packed set of spheres. It’s usefull when you are simulating a block of material and want its initial rest configuration to be at its most packed state.

The code contains two functions, addHCPSheet and addHCPCube; addHCPCube creates layers of sheets using the addHCPSheet function. The input to addHCPCube is the number of particles in each dimension of the cube, the sphere radius and the global 3D position of the cube.

The code is not optimal, I usually only use it to generate particles at the begining of the simulation so the overhead incurred by division operations is not that much.

Run Gentoo on Android via Chroot 2012-11-21

What is Chroot?

Well it’s not a virtual machine or emulation, it’s an honest to goodness linux install…running inside of another linux install. Inception style.

Chroot in essence is a method of running a linux distribution that is not at the standard “/” location, for example in this guide gentoo will be running in /data/local/mnt/. You then “chroot” to that directory and voila you have jumped into that linux distribution and can proceed as if you were running linux natively.

This guide will provide instructions on how to install gentoo on an android tablet. It is assumed that you are doing this on a unix system (debian, gentoo, fedora ubuntu etc) (syntax for some commands might be slightly different for different distributions

Familiarity with a linux environment is required and i assume that some blanks can be filled in, we are installing gentoo after all ;)

First I’d like to thank the people over at linuxonandroid for providing the bootscripts which I based mine off of.

Requirements

  1. Rooted android tablet with superuser (in this case i’m using a Nexus 10)
  2. A compiled version of busybox-android get it here (Full credit for this goes to Stephen (Stericson) )
  3. Android Terminal Emulator

Creating the Image

All steps in this part will be performed on your linux install. we will copy this image to the device later

Create a linux image using dd

Configure this to the size you want, the filesystem of the sdcard partition on your device might be a limitation.

dd if=/dev/zero of=gentoo.img bs=1M count=0 seek=3072

Run mkfs.ext2 on it

NOTE: depending on the size of your partition you may have to increase the number of inodes availible
mkfs.ext2 -F gentoo.img

Download the gentoo stage3 bz2 from:

http://distfiles.gentoo.org/releases/arm/autobuilds/current-stage3-armv7a/

Scientific Rendering Using Mitsuba - Physically Based Renderer 2012-11-19

To render some of my simulations I have recently started using Mitsuba as a quick way to get a nice visualization. The scene description file is very well documented Here. In this post I am going to provide some example code to show how I setup a scene description, stage the simulation data to render and finally render the data.

Mitsuba Example

Rigid Body Dynamics Part 1 2012-11-19

This is part 1 of a multipart series in which I will be discussing the basics of rigid body dynamics. For simplicity I will start out with the frictionless case and the geometry used will only consist of spheres. Constraints considered will only be of the contact variety.

In part 1 I will go over a very high level overview of the steps involved with solving the frictionless problem along with some of the math behind the problem.

The Rigid Body Dynamics Problem

\[\begin{bmatrix} M & D\\ D^T & 0 \end{bmatrix}* \begin{bmatrix} q \\ \lambda \end{bmatrix}- \begin{bmatrix} f \\ b \end{bmatrix}= \begin{bmatrix} 0 \\ c \end{bmatrix}\]

By taking the Shur Compliment of the system of equations the problem can be posed as a minimization problem in the form:

\[min \ q(\lambda)=\frac{1}{2} \lambda^TN\lambda+r^T\lambda \\ N=D^TM^{-1}D \\ r=b+D^TM^{-1}f\]

Subject to the following constraints

\[\lambda \geq 0 , c \geq 0 , \lambda c=0\]

This quadratic optimization problem can then be solved in a straightforward manner.

\[N\lambda=r\]

Complementarity Condition

The complementarity condition states that either the lagrange multiplier is greater than zero (constraint is not satisfied) or the gap between two bodies is zero and therefore there is no reaction force. If the gap becomes 0 a contact has occurred and a reaction force will be applied. The reaction force results from the nonzero lagrange multiplier.

\[ 0 \leq D^{(l)T}M^{-1}D^{(l)} \lambda^{(l+1)} + k^{(l)} \perp \lambda^{(l+1)} \geq 0 \]

Details

(Work in Progress)

Index of Symbols