Direction to Rotation

Discussions about SOFTIMAGEs© Interactive Creative Environment©
iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Direction to Rotation

Post by iamVFX » 24 Dec 2012, 15:33

That is a cool node. Does someone knows the math behind it? Or how it called in mathematical term?

Image

User avatar
Mathaeus
Posts: 1778
Joined: 08 Jun 2009, 19:11
Location: Zagreb, Croatia

Re: Direction to Rotation

Post by Mathaeus » 24 Dec 2012, 16:19

I'd believe it's Rotation_matrix. Btw well known Isner's page about rotations in XSI seem to be still alive.
Yeah it's cool, just as direction constrain from standard XSI kinematics.

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 13:31
Skype: csaezmargotta
Location: Sydney, Australia

Re: Direction to Rotation

Post by csaez » 24 Dec 2012, 17:11

I think it's doing a simple cross product to get the 3 axes and construct a rotation matrix with them.

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: Direction to Rotation

Post by iamVFX » 24 Dec 2012, 21:00

Mathaeus wrote:I'd believe it's Rotation_matrix. Btw well known Isner's page about rotations in XSI seem to be still alive.
Yeah it's cool, just as direction constrain from standard XSI kinematics.
Thanks, Mathaeus! Will read it later
csaez wrote:I think it's doing a simple cross product to get the 3 axes and construct a rotation matrix with them.
Yea, it's an obvious part, but how did it gets second vector for cross product? :-\ I mean it takes only one vector (point at) and the other one is just an axis chooser...

The only way to get two vectors from one position I can see so far is to get the vectors from global center. One for current position of the object, second is for Point At vector. Since they're should't be placed at the same place we will always get the offset which leads us to bi-normal of the object. In cases when they're placed on one axis we apply special case for each of the planes. Right? It is working, but the order of flipping is not matched with the Direction to Rotation node, so it would be great to know how it's actually calculated inside...

Image
You do not have the required permissions to view the files attached to this post.

User avatar
Mathaeus
Posts: 1778
Joined: 08 Jun 2009, 19:11
Location: Zagreb, Croatia

Re: Direction to Rotation

Post by Mathaeus » 24 Dec 2012, 21:27

iamVFX wrote: The only way to get two vectors from one position I can see so far is to get the vectors from global center. One for current position of the object, second is for Point At vector.
In ICE node, both vectors are directions, "point at" is a bit confusing. At least, I've used this node in this way. Kristinka Hair is full of this node. For "point at" should be some subtract or like. So most likely it is, probably, two cross-products for conversion into rotation matrix - first to find third vector, second to line up the "up vector" direction.

Falam

Re: Direction to Rotation

Post by Falam » 24 Dec 2012, 23:59

This could be a thread on asking questions about each individual node in ICE and how it works etc.

face
Posts: 57
Joined: 10 Jan 2010, 11:28

Re: Direction to Rotation

Post by face » 25 Dec 2012, 07:46

Have made a c++ function with the SDK. I thing the compound will work the same...

face

Code: Select all

void LookAt(CVector3 dir, CVector3 up, CMatrix3& m)
{
	CVector3 z(dir);
	z.NormalizeInPlace();
	CVector3 x;
	x.Cross(up, z);// x = y cross z
	x.NormalizeInPlace();
	CVector3 y;
	y.Cross(z, x); // y = z cross x

	m.SetValue(0,0,x[0]);
	m.SetValue(0,1,x[1]);
	m.SetValue(0,2,x[2]);
	m.SetValue(1,0,y[0]);
	m.SetValue(1,1,y[1]);
	m.SetValue(1,2,y[2]);
	m.SetValue(2,0,z[0]);
	m.SetValue(2,1,z[1]);
	m.SetValue(2,2,z[2]);
}

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: Direction to Rotation

Post by iamVFX » 25 Dec 2012, 12:15

face wrote:Have made a c++ function with the SDK. I thing the compound will work the same...

face

Code: Select all

void LookAt(CVector3 dir, CVector3 up, CMatrix3& m)
{
	CVector3 z(dir);
	z.NormalizeInPlace();
	CVector3 x;
	x.Cross(up, z);// x = y cross z
	x.NormalizeInPlace();
	CVector3 y;
	y.Cross(z, x); // y = z cross x

	m.SetValue(0,0,x[0]);
	m.SetValue(0,1,x[1]);
	m.SetValue(0,2,x[2]);
	m.SetValue(1,0,y[0]);
	m.SetValue(1,1,y[1]);
	m.SetValue(1,2,y[2]);
	m.SetValue(2,0,z[0]);
	m.SetValue(2,1,z[1]);
	m.SetValue(2,2,z[2]);
}
Thank you, Stephan! This is exactly what I was looking for :)
Mathaeus wrote:So most likely it is, probably, two cross-products for conversion into rotation matrix - first to find third vector, second to line up the "up vector" direction.
Yes, Mathaeus, you're right, two cross products, and it works exactly like Direction to Rotation compound

Thanks to everyone, guys, I love you :ymhug:

User avatar
dwigfor
Posts: 395
Joined: 17 Nov 2009, 16:46

Re: Direction to Rotation

Post by dwigfor » 26 Dec 2012, 03:55

I thought I tried recreating LookAt function with that double cross product method, and encountered weird flipping issues around poles. Then I discovered that Direction to Rotation node which didn't seem to have that problem.

Or maybe that was when I tried using arctan2, axis and angle.... Any flipping problems you've encountered?

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: Direction to Rotation

Post by iamVFX » 26 Dec 2012, 09:50

dwigfor wrote:Any flipping problems you've encountered?
No... Try it yourself, maybe I missed something
You do not have the required permissions to view the files attached to this post.