Skip to content

Instantly share code, notes, and snippets.

@andreberg
Created November 17, 2020 17:47
Show Gist options
  • Save andreberg/34e5e0d17dd309acd7a7a65497aa4b04 to your computer and use it in GitHub Desktop.
Save andreberg/34e5e0d17dd309acd7a7a65497aa4b04 to your computer and use it in GitHub Desktop.
[Read Point Attrib Values] Example for converting quaternions to euler angles. #houdini #hom #python #attribs
# read geometry from input node (otherwise inf recursion error)
n = pwd().inputs()[0]
g = n.geometry()
# here's how you access point attrib values from the geometry
# orient is a list of float values
orient = g.pointFloatAttribValues("orient")
x = orient[0]
y = orient[1]
z = orient[2]
w = orient[3]
# construct quaternion and convert to Euler angles
quat = hou.Quaternion(x,y,z,w).normalized()
R = quat.extractRotationMatrix3()
rotate_order = pwd().parm("rOrd").evalAsString()
euler_rot = hou.Matrix4(R).explode(rotate_order=rotate_order)["rotate"]
return euler_rot[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment