Jump to content

Learning challenge Vex


girtab

Recommended Posts

If you remember the last picture I posted after the poly frame create a wrangle :
v@up = cross(v@tangentv, v@tangentu);
v@at = v@tangentv;

 

after that a new wrangle:

float pt01 = float(i@ptnum)/float(i@numpt);

pt01 = chramp("shape", pt01);

matrix m = ident();
float angle = radians(ch("angle")*pt01*100);
vector axis = v@tangentu;
vector Newm;

rotate(m, angle, axis);

v@at *= m;

and your @at is twist

Link to comment
Share on other sites

Is it a correct way to do a three-axis rotation with the matrix?

// DEFINE VARIABLES
// Rotation matrix
matrix3 matrx = ident();
// Angle control with UI
float angle_X = radians( chf('angle_X') );
float angle_Y = radians( chf('angle_Y') );
float angle_Z = radians( chf('angle_Z') );
// Define rotation axis
vector axis_X = {1, 0, 0};
vector axis_Y = {0, 1, 0};
vector axis_Z = {0, 0, 1};

// BUILD FUNCTIONALITY
// Rotate matrix by axis
rotate ( matrx, angle_X, axis_X); 
rotate ( matrx, angle_Y, axis_Y); 
rotate ( matrx, angle_Z, axis_Z); 

// Apply rotation: multiply position by matrix
@P *= matrx; 

 

Edited by kiryha
Link to comment
Share on other sites

I'm not very good on matrix but you can use matrix with so many way.

using quaterion matrix3 ect..

there is an ther way to achieve this exercice without matrix.
replace the second wrangle by that:
 

float pt01, twistx, twisty;
vector x, y, z;

x = v@tangentv;
y = v@up;
z = v@tangentu;

pt01 = float(i@ptnum)/float(i@numpt);

twistx = sin(pt01 * ch("amount")) * ch("strength");
twisty = cos(pt01 * ch("amount")) * ch("strength");

x *= twistx;
y *= twisty;

v@at = x + y;

v@N = v@tangentu;
v@up = v@at;
 

Link to comment
Share on other sites

I did not find a more elegant way of three-axis rotations with matrix but with quaternions it is: 

float angle_X = radians(chf('angle_X'));
float angle_Y = radians(chf('angle_Y'));
float angle_Z = radians(chf('angle_Z'));

vector rotations = set(angle_X,angle_Y,angle_Z);
@P = qrotate(quaternion(rotations), @P);

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...