Showing posts with label rotation. Show all posts
Showing posts with label rotation. Show all posts

Monday 7 October 2024

random spin to particles/packed rigid bodies

stolen from a Toadstorm reply somewhere...

axis might be more finessed than just setting to z as shown.. Same goes for the angle, which I've brute forced to -90 times. Anyway, this will give a bit of spin to your packed rigid bodies


vector axis = set(0,0,1); // the random axis attribute you created

float angle = -90*fit01(rand(@ptnum), -1, 1); // change this to whatever range, in radians

vector4 q = quaternion(angle, axis);

v@w = qconvert(q);


Monday 9 March 2020

Rotation in vex

Rotation round an arbitrary axis, in vex

nicked from Rich Lord's handy notes and scenes - https://www.richlord.com/tools/
Placed here, jusssst in case it all vanishes!
The general gist is -


  1. define an axis to rotate around
  2. specify the angle of rotation
  3. create an identity matrix
  4. rotate the matrix by the angle, along the axis
  5. multiply the Position of each point by the transformed matrix

Here's the code -
vector axis = normalize(chv("rotate_axis"));
float angle = radians(chf("rotate_angle"));
// create the matrix representing the rotation, and rotate the points
matrix3 m = ident();
rotate(m, angle, axis);
@P *= m;
Be sure to press the create slider/input button!

A separate example Rich provided has the points rotate around a point in space -

The same technique applies, except a little bit of subtraction/addition of the point position (we move the points-to-be-rotated to the position-of-the-rotation-origin first). Pretty useful, as you're probably not just doing everything at the origin :D

Code -
vector rotate_point = chv("rotate_point"); //this is the origin of the rotation
vector axis = normalize(chv("rotate_axis")); //the axis
float angle = radians(chf("rotate_angle")); //the angle of rotation...
// move the points before the rotation
@P -= rotate_point;
// build the matrix that does the rotation and apply it to the points
matrix3 m = ident();
rotate(m, angle, axis);
@P *= m;
// move the points back to their original position
@P += rotate_point;

Tuesday 28 May 2019

spinning particles/points/rbds

I made a previous post about spinning particles with "w" and Pop Torque.... Walter uses this & it seems much simpler (?). In your DOP network, create a Pop Spin node & in the VEXpression space type:

spinspeed = 100*(fit01(rand(@id),chf("min"),chf("max")));
axis = sample_direction_uniform(rand(@id));


Spinspeed is measured in degrees per second
Axis specifies the axis of each point you're spinning. The sample_direction_uniform() function returns a normalised vector. So here, we have a completely randomised rotation axis. Not bad.

Thursday 22 March 2018

alembic rotation transform

matrix m = primintrinsic(0,'packedfulltransform',@ptnum);@orient = quaternion(matrix3(m)); 


Stole this from odforce. I'm unsure whether it's meant to be in a point or primitive wrangle (and then promoted to the other). I managed to get it working in just a point wrangle..This helps you get rotational values from an alembic'd object (v. handy!)

Wednesday 5 October 2016

using object's rotation as a vector value.

A simple method would be to set the world aligned object's vector value to pure X,Y or Z (eg <<1,0,0>> for all X)before it ever gets transformed. As long as inherit attributes is active, the vector will also be transformed/rotated etc)
Useful for setting vectors to point in the direction of the object.