Importing Into Maya From Physics Engine 2013-09-28

Maya is a useful tool for visualizing simulation results. However sometimes coordinate systems get messed up when loading in data.

Using A vector for position and a quaternion for rotation we have:

Negate the X direction

maya_pos.x = -original_pos.x;
maya_pos.y =  original_pos.y;
maya_pos.z =  original_pos.z;

Negate the Quaternion’s x component and magnitude

maya_quat.e0 = -original_quat.e0
maya_quat.e1 = -original_quat.e1
maya_quat.e2 =  original_quat.e2
maya_quat.e3 =  original_quat.e3

Maya does not have direct support for quaternions but if you use python you can use the OpenMaya module

import maya.OpenMaya as OpenMaya
...
rotation = OpenMaya.MQuaternion(-e1,e2,e3,-e0);
euler = rotation.asEulerRotation().asVector();

And then use the euler angles as normal, converting them to degrees as needed

Installing cuda sdk 5.0 on fedora 18 2013-03-14

This guide assumes a 64 bit architecture First install gcc 4.6.3 using this guide

Compiling GCC 4.6.3

Compiling GCC 4.6.3 on Fedora 18 2013-03-14

This guide assumes a 64 bit architecture First get gcc 4.6.3

GCC 4.6.3

Extract the tar

tar -xvf gcc-4.6.3.tar.gz

Install wget (required by prequesites command), development tools and 32 bit glibc headers

yum install wget glibc-devel.i686
yum groupinstall "Development Tools"

Enter the directory, download prerequisites and run configure with prefix to set the install directory, change this to your liking

cd gcc-4.6.3/
./contrib/download_prerequisites
./configure --prefix=/usr/local/gcc/4.6.3

A compilation error will result when you run make so either apply the following patch or change the lines modified by the patch

patch -p1 < {/path/to/patch/file}

OR

nano gcc/config/i386/linux-unwind.h

Patch:

--- a/gcc/config/i386/linux-unwind.h	2011-01-03 20:52:22.000000000 +0000
+++ b/gcc/config/i386/linux-unwind.h	2012-07-06 12:23:51.562859470 +0100
@@ -133,9 +133,9 @@
     {
       struct rt_sigframe {
 	int sig;
-	struct siginfo *pinfo;
+	siginfo_t *pinfo;
 	void *puc;
-	struct siginfo info;
+	siginfo_t info;
 	struct ucontext uc;
       } *rt_ = context->cfa;
       /* The void * cast is necessary to avoid an aliasing warning.

Thrust Reduce by Key Crashes in 64 bit 2013-03-03

Source for fix

The problem seems to only happen when compiling for 64 bit architectures. I have experienced this problem and usually ended up copying data to host before doing the reduce operation.

The fix is very simple, open up:

thrust/detail/backend/cuda/reduce_by_key.inl

Find the line that states:

 typedef typename thrust::iterator_traits<InputIterator1>::difference_type  IndexType;

and change it to:

typedef  unsigned int  IndexType;

Reduce by key should now work on the device.

Formatting Code in Xcode with Astyle 2012-12-18

If you’ve ever wanted automatic code formatting in xcode like that in eclipse, it is entirely possible with an automator workflow and astyle.

first install astyle, if using macports:

sudo port install astyle

Then in our home directory we need to create a .astylerc file. This file defines the style for the code formatting. An example is provided below, for more info refer to the documentation.

Example .astylerc :

style=kr
brackets=attach
delete-empty-lines
keep-one-line-blocks
convert-tabs
indent=spaces=8
indent-namespaces  
indent-classes  
indent-cases  
indent-preprocessor  
break-blocks  
pad-oper
unpad-paren  
pad-header  
align-pointer=name
suffix=nonekr