Evan Balster


« on: February 08, 2013, 11:40:49 pm » 

WHO AMONG YOU WILL BE BRAVE?A rotation vector (or SORA rotation) is defined as the axis of rotation (a unit vector) multiplied by the righthanded rotation about that vector in radians. Every 3D rotation is uniquely represented by some rotation vector with magnitude <= pi, and outside this spherical set the space is reflected radially. The space within the sphere, when used to represent rotations, is called SO(3). Rotation vectors are a very nice way of decomposing rotations into three orthogonal variables  euler angles fail to do this adequately. I need to find the partial derivatives of a rotation vector along its cartesian axes, expressed as a "delta" rotation vector of unit length. We require a function D(a, b) which is a rotation vector mapping from the rotation space of rotation vector a to that of rotation vector b. One way to derive it is to convert a and b to rotation quaternions qa and qb, and convert qa^{1}qb back to a rotation vector. This seems roundabout, but perhaps I'm foolish to dismiss it. Given D, the current rotation r and an axisvector a we need to compute the limit: lim D(r, r + ax) x>0 xI'm interested in these limits for a = (1, 0, 0), a = (0, 1, 0) and a = (0, 0, 1). The application area is kinematics solving; I'm trying to find an optimal rotation in a leastsquares solver and I need to separate a rotation into orthogonal variables.



Logged

Creativity births expression. Curiosity births exploration. Our work is as soil to these seeds; our art is what grows from them...Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>



JakobProgsch


« Reply #1 on: February 09, 2013, 01:58:56 am » 

I don't get what a "rotation space" is supposed to be? A vector gives you a specific rotation, what is the "space" you associate with that?



Logged




HernanZh


« Reply #2 on: February 09, 2013, 02:31:08 am » 

I don't get what a "rotation space" is supposed to be? A vector gives you a specific rotation, what is the "space" you associate with that?
He means the vector space that is made up by the set of rotation vectors. I think I sort of get the problem, but I wouldn't know where to start with solving it



Logged




JakobProgsch


« Reply #3 on: February 09, 2013, 02:41:52 am » 

But that doesn't make sense with something like: "...from the rotation space of rotation vector a...".
The bit about quaternions makes me now think that this is just a complicated way to ask for a change of basis though?



Logged




BorisTheBrave


« Reply #4 on: February 09, 2013, 03:50:51 am » 

It's a legit question. I don't see why you'd want to use a rotation representation like that over quaternions though  wikipedia seems to suggest the only reason is that is the output of certain 3d gyroscopes.
I haven't been able form a full answer (short of doing the tedious quaternion conversion process), but I think the trick is to use various small angle approximations for rotations to simplify rotate(compose(inverse(r), r+ax), r+y) into rotate(x z, r+y) for some z for all small y, at which point the answer is z.



Logged




BorisTheBrave


« Reply #5 on: February 09, 2013, 04:16:25 am » 

Suppose a is perpendicular to r, and b parallel.
Then D(r, r+ax+bx) = D(r, r+ax) + D(r,r+bx) for small x.
D(r, r+bx) = b x, should be clear enough with a bit of thought.
I use two approximations without any justification:
1) rotate(z, r+y) = r+y + cross(z, r) for small z perpendicular to r, small y.
2) rotate(r+x, r+y) = rotate(r, r+yx) + x for small x, y
So, by (2)
rotate(D(r, r+ax), r+y) = rotate(inverse(r), rotate(r+ax, r+y)) = r+yax + rotate(inverse(r), ax)
so suppose D(r, r+ax) = x z, with z perpendicular to r.
Then by (1)
rotate(D(r, r+ax), r+y) = rotate(x z, r+y) = r+y+cross(x z, r+y)
Comparing with above, and simplifying we get.
cross(z, r) = a + rotate(inverse(r), a)
cross(r, cross(z, r)) = cross(r, a + rotate(inverse(r), a)) z = cross(r, a + rotate(inverse(r), a)) / r^2
So there you have it, give or take a few minus signs.
D(r, r+ax+bx) / x > b + cross(r, a + rotate(inverse(r), a)) / r^2
Note, I've equated two rotations by showing them to be linearly equal when acting on the range of points r+y for small y. Due to the nature of SO(3), this is sufficient for them to be equal rotations.



Logged




PompiPompi


« Reply #6 on: February 09, 2013, 05:44:46 am » 

Yea, I don't get what you are trying to derive. You can't just say "deriving rotation", it has to be a rotation of something. You are suppose to derive a function of rotation. I don't think you can get any more than what you already wrote if you derive a completely generic function. Maybe you mean to derive some specific function, but then you need to ask how to find this function, not how to derive a generic function. Maybe all you need to do is represent your rotation from your rotation space or whatever, in the Cartesian space, and then derive that. Other than that I didn't really follow much.



Logged

Master of all trades.



Evan Balster


« Reply #7 on: February 09, 2013, 12:21:23 pm » 

Clarifications on my use of terms: Rotation space  a transformation from nonrotated space (some default position) to the same set of points rotated by a given rotation vector or other operation. R(a) = R(0) rotated by vector a; for the sake of this post I'll express this as R(R(0), a). As with other sorts of transform spaces, a point outside the space is brought into it by applying the space's transformation. A point inside is taken out by applying the inverse transformation, R^{1}(a), which is R(a). Due to the frequent need for inversions I avoid matrices. Any rotation space can be expressed as a point on a unit hypersphere (a quaternion versor) or one of thee rotation vectors. Delta rotation D(a, b)  a delta rotation from space R(a) to space R(b). Can be derived as R(R^{1}(a), b). Again expressible as a rotation vector. Boris  you're living up to your name. I'm working on getting my head around your derivation, and I want to make sure you've accounted for something. Since SO(3) isn't quite like cartesian space (rotation "vectors" is a misleading term) you can't compose two rotations by applying one vector's rotation to the other. For instance given a = (1, 0, 0) and b = (0, 1, 0), R(R(a), b) != (0, 0, 1).



Logged

Creativity births expression. Curiosity births exploration. Our work is as soil to these seeds; our art is what grows from them...Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>



PompiPompi


« Reply #8 on: February 09, 2013, 01:06:35 pm » 

Is that the Gauss sphere or whatever? I forgot. Anyway, you usually derive a curve on these spaces and compare the cure from the original space to the target space. But I really don't remember this material and I am not sure you are using the formal names. I am also not sure what exactly do you want to do.



Logged

Master of all trades.



BorisTheBrave


« Reply #9 on: February 09, 2013, 01:39:31 pm » 

Boris  you're living up to your name. I'm working on getting my head around your derivation, and I want to make sure you've accounted for something. Since SO(3) isn't quite like cartesian space (rotation "vectors" is a misleading term) you can't compose two rotations by applying one vector's rotation to the other. For instance given a = (1, 0, 0) and b = (0, 1, 0), R(R(a), b) != (0, 0, 1). Uh, sorry, should have explained my notation a bit better. I've been actually using your embedding of SO(3) in R(3), the SORA, hence why I've been doing things like addition scaling and rotation. Any explaination is going to have to do that, or else it's not deriving something specific to SORA! So by rotate(a, b), I mean treat b as a vector and a as a rotation. inverse(a) means the inverse as a rotation, which coincidentally is equal to a when considered as a vector. So for your given values R(a, b) means rotate (0,1,0) 1 radians around (1, 0, 0), which is (0, cos 1, sin 1).



Logged




Evan Balster


« Reply #10 on: February 09, 2013, 04:46:18 pm » 

Right, sorry, I should have said (pi, 0, 0) and (0, pi, 0) don't compose to (0, 0, pi). In any case you've got a much better grip on all this than I do.
Thanks for clarifying what you meant with that rotate() operation; that more or less clears up my confusion and I understand your derivation now. I'll think this over some more and give it a try...
<3



Logged

Creativity births expression. Curiosity births exploration. Our work is as soil to these seeds; our art is what grows from them...Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>



Evan Balster


« Reply #11 on: February 12, 2013, 12:04:45 pm » 

Boris 
I went over this problem in my head quite a few times, visualizing it and such. Your solution was bothering me because it seemed as though it could output nonunit vectors for unit vector inputs and in my limited understanding the rotation space maintains properties of axisorthogonality and continuous "rotationspeed" throughout. These properties and the property of b you mentioned implied the delta limit I was searching for was a simple rotation of the axis vector about r. I strongly suspected that rotation to be the one defined by r itself.
I wrote out some tests today and it appears your formulation was correct. However, my suspicion was also apparently correct  the limit of Delta(r, r+ax)/x appears to converge to rotate(a, r/2), which is equivalent to your formula. (Let me know if I've made an error in this analysis!) This form is more numerically stable around the origin as it avoids the divisions.
I *think* I've got the right solution now, and will be able to proceed. Time will tell, I suppose. Thanks again for your invaluable help in solving this problem.



Logged

Creativity births expression. Curiosity births exploration. Our work is as soil to these seeds; our art is what grows from them...Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>



BorisTheBrave


« Reply #12 on: February 12, 2013, 02:14:44 pm » 

Good lord, it worked without fixing?
I have no idea how you can equate your formula with mine. Yours looks much neater though.



Logged




Jimym GIMBERT


« Reply #13 on: February 12, 2013, 06:00:03 pm » 

Looks like something I may need if only my brain weren't furiously spinning right now



Logged




Evan Balster


« Reply #14 on: February 12, 2013, 07:43:23 pm » 

Looks like something I may need if only my brain weren't furiously spinning right now At what rate? Give me a derivative! D: So anyway rotation vectors are neat. You can represent kinematic joint limits neatly as ellipsoids in rotationvectorspace and that is a Nice Thing.



Logged

Creativity births expression. Curiosity births exploration. Our work is as soil to these seeds; our art is what grows from them...Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>



BorisTheBrave


« Reply #15 on: February 13, 2013, 12:52:23 pm » 

I don't really get the point. Quaternions can be represented like that too, if you just take the i,j,k components. And do a dozen other useful things.



Logged




Evan Balster


« Reply #16 on: February 13, 2013, 02:44:40 pm » 

The nice thing about rotation vectors is they're welldefined for the whole vector space. I can easily decompose them into arbitrary scalars, so I can use heuristic solver algorithms with them as variables.



Logged

Creativity births expression. Curiosity births exploration. Our work is as soil to these seeds; our art is what grows from them...Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>



Jimym GIMBERT


« Reply #17 on: February 13, 2013, 05:15:55 pm » 

For example I'm trying to make a relative cam movement around a character moving along arbitrary surface (can be summarize as movement on a sphere, which is all surfaces orientations), right now I have all sort of singularity either on pole or on "inflated cube" corner. Doubly so because, character/camera dependence, the forward input acceleration is the relative camera forward and the character must align "first" to the camera direction, they share orientation except their "Y" (rotation around the character) except when I press a direction because the character should orient with the camera slowly. Also I have no absolute coordinate in the Y relative to surface, (at least in unity, euler angle are converted internally into quaternion), therefore the Y euler value spin furiously for relatively "straight" movement on a curved surface. That drive me crazy. It looks like something that might help if I could understand but brain cells are pretty burn out those days ... and then there is game like Sophie Houlden's Sarah's run who have that and certainly don't go that complex ... what I'm doing wrong?



Logged




Evan Balster


« Reply #18 on: February 14, 2013, 08:24:23 am » 

Uhh, well, basically you could view that as an overdetermined system if you wanted to. You have several goals, which potentially conflict with each other:  Keep the camera's forward vector pointing at X.
 Keep the camera's up vector at some reasonable orientation.
 Don't move the camera so much in a single frame that it's disorienting.
 Keep the camera at a reasonable distance from X.
These can be redefined into scalarvalued optimization functions where 0 is an ideal result and values are progressively "worse" as they become further from zero. For instance, goal 3 could be defined as functions which measure the position and rotation delta from one frame to the next, possibly with a deadzone. That function is zero when the amount of movement is completely acceptable. You have these variables which you may manipulate in order to optimize your functions as close to zero as possible:  The position of the camera in worldspace. (3 degrees of freedom: x, y, z)
 The rotation of the camera in worldspace. (3 degrees of freedom, can be decomposed in many ways)
A leastsquares solver, given the variables to manipulate, the functions to evaluate, and (optionally, helps a lot) the partial derivatives of each function for each variable, will search for variable values that reduce the sum of the squared values of the optimization functions as possible. If all functions can be optimized to zero, it will do so. Otherwise (IE when there is a conflict between the goals) it will distribute the squared error as evenly as it can. It's an iterative algorithm with some tunable settings, so the more CPU you give it the better it does. It might be overkill for camera controls (*might be*) but it's really useful to learn how to use these  they're the basis of physics simulation, IK and a lot of other complex problems and leastsquares can be used to solve just about anything that can be decomposed into continuous functions. I use CMinPack. Start a new thread if you want more specific counsel...



Logged

Creativity births expression. Curiosity births exploration. Our work is as soil to these seeds; our art is what grows from them...Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>



