Skip to content

Instantly share code, notes, and snippets.

@baku89
baku89 / mat2quat.py
Created Nov 1, 2015
Extract quaternion in right-hand rule from affine matrix in left-hand rules
View mat2quat.py
# http://afni.nimh.nih.gov/pub/dist/src/pkundu/meica.libs/nibabel/eulerangles.py
import eulerangles
import c4d
threeMat = c4d.Matrix().Scale(c4d.Vector(1, 1, -1))
def mat2quat(mat):
mt = threeMat * m
v1, v2, v3 = mat.v1, mat.v2, mat.v3
rotMat = [
@Squid3d
Squid3d / Walking_with_yield.py
Created Mar 5, 2015
using yield to iterate c4d object/tag and materials
View Walking_with_yield.py
import c4d
def walk_objects(obj):
if obj:
yield obj
for x in walk_objects(obj.GetDown()): # happily fail on tags and materials
yield x
for x in walk_objects(obj.GetNext()):
yield x