how to rotate() around custom axis?
10799 9 0- ykcosmo
- Member
- 288 posts
- Joined: July 2005
- Offline
- Mario Marengo
- Member
- 941 posts
- Joined: July 2005
- Offline
ykcosmo
I want to rotate my v around the axis which is the cross product of my N and v, I tried rotate(35, cross(points(“../a,$PT,”N“), points(”../b“,$PT,”v"))), it shut down my houdini at once….
Judging by your syntax, I'll assume you're talking about hscript and not VEX.
The function points() returns a string, and is meant for fetching string attributes, not numerical ones – you're clearly looking for a number not a string, so you'd need to use point() instead.
The function rotate() returns a matrix, and is meant to post-multiply your “v” in order to transform it. However, it can only rotate about three predefined axes: the basis vectors “x”, “y”, and “z”, which is not what you want in this case. To rotate by an arbitrary axis, you want to use the function rotaxis().
Putting it all together, and assuming the vector to be rotated (“v”) is locally available as , you'd end up with something like this:
{
float ax = point(“../a”,$PT,“N”,0);
float ay = point(“../a”,$PT,“N”,1);
float az = point(“../a”,$PT,“N”,2);
vector a = vector3(ax,ay,az);
float bx = point(“../b”,$PT,“v”,0);
float by = point(“../b”,$PT,“v”,1);
float bz = point(“../b”,$PT,“v”,2);
vector b = vector3(bx,by,bz);
vector v = vector3($VX,$VY,$VZ);
float angle = 35; # <-some expression for angle goes here
return (v*rotaxis(angle,cross(a,b)));
}
The array index at the end "“ extracts element zero of the result (i.e: ”x"), you'd change it to or to extract y and z respectively, or remove it altogether if you want the whole vector returned.
… and you can write it all in a single line if you wish. I split it up for clarity, not because you have to.
HTH.
- ykcosmo
- Member
- 288 posts
- Joined: July 2005
- Offline
- EigenAlex
- Member
- 639 posts
- Joined: July 2005
- Offline
- edward
- Member
- 7733 posts
- Joined: July 2005
- Offline
- Mario Marengo
- Member
- 941 posts
- Joined: July 2005
- Offline
edward
Well, if you set up the TransformAxis SOP's parameters correctly, then you can just turn off Recompute Point Normals to rotate N.
How would you set that up?
As I understood it, he wants to rotate a point attribute (vector “v”) of the current geometry (“.”) about an axis that results from the cross product of two point vector attributes (“N” and “v”) which come from two separate external sources (“../a” and “../b”).
Doesn't TransformAxis operate on the whole geometry?
P.S: Sorry ykcosmo. I should have said “houdini expression language” (HEL? ) instead of “hscript”. We're talking about the same thing.
- edward
- Member
- 7733 posts
- Joined: July 2005
- Offline
- ykcosmo
- Member
- 288 posts
- Joined: July 2005
- Offline
- edward
- Member
- 7733 posts
- Joined: July 2005
- Offline
- ykcosmo
- Member
- 288 posts
- Joined: July 2005
- Offline
-
- Quick Links