Page 1 of 1
How to solve the gimbal lock in .NET?
Posted: Fri Jul 15, 2005 6:42 pm
by SpacePowo
Does Irrlicht happen to have any type of feature where you can do some free degrees of rotation as in pitch, yaw and rolling??
Or do we have to do some calculations itself?
I know how the C++ thing can be done but what about C#.NET?
Posted: Tue Jul 19, 2005 7:33 pm
by Aire
I am unsure how Irrlicht approaches rotations at the moment, I am guessing using matrices. I myself prefer quaternions because they all together avoid the gimbal lock. But, I am not quite sure what you are looking for here. Are you looking for a way to use Euler (yaw/pitch/roll) Angles and translate them to the native Irrlicht rotation methods?
Posted: Thu Jul 21, 2005 3:31 am
by SpacePowo
Anything that gets me out of a gimbal lock..
Yeah Pitch, Yaw and Roll.
Posted: Sat Jul 23, 2005 6:49 am
by SpacePowo
I've tried this method in ittlicht using VB.NET instead:
'Yaw
X = zpos(i) * Sin(Yaw) + xpos(i) * Cos(Yaw)
Y = ypos(i)
z = zpos(i) * Cos(Yaw) - xpos(i) * Sin(Yaw)
'Pitch
X2 = X
y2 = Y * Cos(Pitch) - z * Sin(Pitch)
Z2 = Y * Sin(Pitch) + z * Cos(Pitch)
'Roll
x3 = y2 * Sin(Roll) + X2 * Cos(Roll)
Y3 = y2 * Cos(Roll) - X2 * Sin(Roll)
z3 = Z2
And the rotation didn't go well.
If someone can provide an example either in VB.NET or C#.NET, then I would be happy camper. I'm too lazy to do it right myself since it's late at night.
Though there seems to be a lack of examples provided with the .NET framework.
Posted: Sat Jul 23, 2005 6:54 am
by SpacePowo
I've tried this method in ittlicht using VB.NET instead:
'Yaw
X = zpos(i) * Sin(Yaw) + xpos(i) * Cos(Yaw)
Y = ypos(i)
z = zpos(i) * Cos(Yaw) - xpos(i) * Sin(Yaw)
'Pitch
X2 = X
y2 = Y * Cos(Pitch) - z * Sin(Pitch)
Z2 = Y * Sin(Pitch) + z * Cos(Pitch)
'Roll
x3 = y2 * Sin(Roll) + X2 * Cos(Roll)
Y3 = y2 * Cos(Roll) - X2 * Sin(Roll)
z3 = Z2
And the rotation didn't go well.
If someone can provide an example either in VB.NET or C#.NET, then I would be happy camper. I'm too lazy to do it right myself since it's late at night.
Though there seems to be a lack of examples provided with the .NET framework.
Edit: I noticed the previous code it used for making 3D drawings on a 2D screen.
Posted: Sat Jul 23, 2005 12:01 pm
by Sergio Cossa
Hi!
I don't still know a lot of develop in games 3D and Irrlicht, but I am making some tests with code that appears in this post:
http://irrlicht.sourceforge.net/phpBB2/ ... ra&start=0
There are some samples in c++ and an adaptation that made for C#. It is not complete, but with something of effort one can make run.
Some day the community. NET of Irrlicht will have thousands of examples to advance more quickly

Posted: Sat Jul 23, 2005 7:46 pm
by SpacePowo
I am having a hard time converting this to VB.NET.
I am taking one segment at a time and putting it in to the VB code.
In C#
Code: Select all
//--- rotate node relative to its current rotation -used in turn,pitch,roll ---
public static void Rotate(Irrlicht.Scene.ISceneNode node, Irrlicht.Core.Vector3D rot) {
Irrlicht.Core.Matrix4 m = node.RelativeTransformation;
Irrlicht.Core.Matrix4 n = new Irrlicht.Core.Matrix4();
n.SetRotationDegrees(rot);
m *= n;
node.Rotation = getRotationDegrees( m );
}
TO VB.NET
Code: Select all
Public Sub Rotate(ByVal node As Irrlicht.Scene.ISceneNode, ByVal rot As Irrlicht.Core.Vector3D)
Dim m As Irrlicht.Core.Matrix4 = node.RelativeTransformation
Dim n As Irrlicht.Core.Matrix4 = New Irrlicht.Core.Matrix4
n.SetRotationDegrees(rot)
m *= n
node.Rotation = getRotationDegrees(m)
End Sub
So is there any where how I can convert where A *= B to VB.NET?
I suppose A=A*B?
Sorry I know a little about C#.
Posted: Sat Jul 23, 2005 8:22 pm
by Irme
you should be able to use *= in vb.net if not yes you would do a = a*b
Posted: Sat Jul 23, 2005 8:50 pm
by SpacePowo
Ok I think I got a compiler error.
C:\Documents and Settings\xxxxxxxxx\My Documents\SharpDevelop Projects\blank\MainClass.vb(222) : error BC30452: Operator '*' is not defined for types 'Irrlicht.Core.Matrix4' and 'Irrlicht.Core.Matrix4'.
m=m*n
Though previously that m*=n in the c# code.
Posted: Sun Jul 24, 2005 7:59 am
by Irme
you may want to see if the matrix4 class has a multiply function built in - if not you will have to multiply each aspect of the matrix4 individualy like this
mat1.x = mat1.x * mat2.x
mat1.y = mat1.y * mat2.y