Skip to content

Instantly share code, notes, and snippets.

@skyburchard
skyburchard / simple remapping
Last active January 2, 2021 00:48
simple remapping equations
//////////////////////////
// -1 to 1 remap to 0 to 1
//////////////////////////
x = x / 2 + 0.5;
//////////////////////////
// 0 to 1 remap to -1 to 1
//////////////////////////
////////////////////////////////////////////////////////
// rotate a point around another point using quaternions
// set quaterion by vector
var quat = Quaternion.LookRotation(Vector3 forward, Vector3 upwards = Vector3.up);
// set quaternion by angle
var quat = Quaternion.AngleAxis(float angle, Vector3 axis);
// rotate around pivit point
float width = chf("width");
float depth = chf("depth");
float halfWidth = width * 0.5;
float halfDepth = depth * 0.5;
vector v0 = set( halfWidth, 0, halfDepth);
vector v1 = set(-halfWidth, 0, halfDepth);
vector v2 = set(-halfWidth, 0, -halfDepth);
vector v3 = set( halfWidth, 0, -halfDepth);
////////////////////////////////
// houdini attributes and groups
////////////////////////////////
///////////////////////
// attributes as groups
// credit here: http://www.tokeru.com/cgwiki/?title=Houdini
// the below can be entered as expressions in any goup field
// not spaces, no semi colon, must be conditional, must be cast using "s, i, f", etc
// floats don't need casting
@skyburchard
skyburchard / glsl_snippets.txt
Last active April 23, 2020 02:22
glsl_snippets
///////////////////////////////////////////////
// glsl snippets: credit given where i could //
///////////////////////////////////////////////
///////////////////
// inverse matrices
// credit to: https://github.com/glslify/glsl-inverse/blob/master/index.glsl
float inverse(float m) {
return 1.0 / m;
@skyburchard
skyburchard / houdini_vex_snippets
Last active April 10, 2023 18:48
houdini vex snippets
///////////////////////
// houdini vex snippets
///////////////////////
// get angle between two vectors ( 0 - 360 dergees )
float angleBetween ( vector v1; vector v2 ) {
// define up vector
vector up = {0.0, 1.0, 0.0};