Help, @orient "360 degree" problem

   1370   6   0
User Avatar
Member
21 posts
Joined: Feb. 2022
Offline
for some reason, I need to use @orient to “rotate” copy-to-points’ orient

at most of time, the vex script works
but if the sphere’s segment is 6,12,24…, when they hit 360 degree(or 0? I’m not sure)
the problem rise (like the pig-heads in picture, they have “opposite” direction)





why this problem happens?
And how to fix it?

Thank you for you help

Attachments:
2023-03-03_10-05-27.jpg (303.8 KB)
2023-03-03_10-13-13.jpg (90.5 KB)

User Avatar
Member
8555 posts
Joined: July 2007
Offline
that code looks like you were trying to throw someone off of your scent
I genuinely got lost

try this
vector up = {0,1,0};
@orient = quaternion(  maketransform( normalize(v@N), normalize(up) ) );
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
21 posts
Joined: Feb. 2022
Offline
tamte
that code looks like you were trying to throw someone off of your scent
I genuinely got lost

try this
vector up = {0,1,0};
@orient = quaternion(  maketransform( normalize(v@N), normalize(up) ) );


I’m a beginning leaner of vex(), the reply really helps me!!
Thanks a loooooooooot !!

As a beginner, still have some doubts in my mind, like

The first one
Still want to know,

Because I’m studying the function like quaternion(),cross(), qmultiply()…..
I really want to know
Why I rotate one axis, then the other, it works, except the 360 degree points
And ,how can I fix it(of course maketransform been learned)(for other scenario or example )
I think if I do not understand the reason, the same problem will happen again and again


Second,
The maketransform don’t work very well with the top and bottom points, witch the N and up axis is the same

If I need, how can I fix this in a good way ?


Thanks again!!!!
Edited by hign - March 3, 2023 22:42:20

Attachments:
2023-03-04_11-34-31.jpg (323.4 KB)
2023-03-04_11-35-13.jpg (302.1 KB)

User Avatar
Member
134 posts
Joined: Dec. 2006
Offline
Hey, I have done something similar, but instead of just using the normals I do a cross between normals and a up vector{0,1,0}.
matrix3 matrix_ = maketransform(v@N,cross(@N,{0,1,0}));
@orient = quaternion(matrix_);
Im not getting any weird flipping on the poles

Attachments:
orient.jpg (357.6 KB)

User Avatar
Member
166 posts
Joined: March 2014
Offline
The poles will typically give you problems because the cross product between identical vectors is 0, i.e. not a valid axis. You can check the dot product between the vectors, and if it's 1, then you'll want to choose a different second vector. So something like:
vector up = set(0, 1, 0);
if (dot(v@N, up) == 1)
  up = set(1, 0, 0);
vector side = cross(v@N, up);
User Avatar
Staff
329 posts
Joined: July 2005
Offline
hign
I really want to know
Why I rotate one axis, then the other, it works, except the 360 degree points
And ,how can I fix it(of course maketransform been learned)(for other scenario or example )
I think if I do not understand the reason, the same problem will happen again and again

The problem with your original code is how to handle situations when @newz and @mytan point in opposite directions. In these situations, dihedral() will return an arbitrary rotation that will map @newz onto @mytan but you want to further constrain it to a rotation that will keep the @N direction unchanged.
Edited by derrick - March 20, 2023 10:13:31
User Avatar
Member
21 posts
Joined: Feb. 2022
Offline
thanks for everyone. still studying it, above notes help a lot!
  • Quick Links