Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Can I get my axis value independent from the values ​​of the other axes?

Author
Message
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 27th Jan 2013 16:52
Hi all, I trying to check the X, Y and Z angle values of an object (an airplane) using object angle x(), object angle y() and object angle z() commands.

The X axis is the airplane ROLL
The Y axis is the airplane YAW
The Z axis is the airplane PITCH

Ok my airplane start to fly and it's all ok but I notice this thing:

When the Y axis exceeds the 90 degrees so I obtain the Z axis value increased (or decreased, depending on the direction of rotation) of other 180 degrees.

When the X axis change so I obtain the aspect ratio between Y and Z changing too.

So, can I obtain a 360 degrees value of my Z axis independently from other axis?
Le Verdier
14
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 28th Jan 2013 18:22
You're refering to what is called "Gimbal Lock" (Loss of a degree of freedom when an angle is 90°)

I think youve reversed the axis:
X axis: Pitch
Y axis: Yaw
Z axis: Roll

Try:
Rotate Object Obj, Pitch#, Yaw#, 0.0
Roll Object Left Obj, Roll#

assuming the standard object rotation mode(XYZ)

The fact is DBP is not good at managing rotations. there is plugins but Ive not tried them. The best way is to use matrix maths. (click on my banner for an example...)

Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 28th Jan 2013 18:55 Edited at: 28th Jan 2013 18:58
Quote: "You're refering to what is called "Gimbal Lock" (Loss of a degree of freedom when an angle is 90°)

I think youve reversed the axis:
X axis: Pitch
Y axis: Yaw
Z axis: Roll

Try:
Rotate Object Obj, Pitch#, Yaw#, 0.0
Roll Object Left Obj, Roll#

assuming the standard object rotation mode(XYZ)

The fact is DBP is not good at managing rotations. there is plugins but Ive not tried them. The best way is to use matrix maths. (click on my banner for an example...)"


Hi Le Verdier and thank you for the answer.
I am really really confused about angles (you are right when you write that I reversed the axis)and I trying just to get my airplane roll, yaw and pitch values (each indipendent from other values and each using 360 degrees).

You telling me to try the code :
Rotate Object Obj, Pitch#, Yaw#, 0.0
Roll Object Left Obj, Roll#

But my airplane is moved by the darkDynamix physic and not from DBPro objects command.
Please tell me if I am too wrong:

To obtain ROLL indipendent value :
I calculate the angle between my two wings objects positions (angle between 2 points) (seems to work good but I fear to tell that..)

To obtain PITCH indipendent value :
I calculate the angle between the aircraft nose object and the airplane tail object.(angle between 2 points) (seems to work good but I fear to tell that too..)

To obtain YAW indipendent value :
I really confused about how to obtain YAW axis.. and I trying some experiments..

What do you (and all other users) think about?
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 28th Jan 2013 18:58
EZrotate should help with this...

There is a basic free version on the forums, try searching for it try searching for EZROTATE BASIC or EZROTATE LITE something like that...

Otherwise yeah try some maths

Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 28th Jan 2013 19:16 Edited at: 28th Jan 2013 19:19
Quote: "EZrotate should help with this...

There is a basic free version on the forums, try searching for it try searching for EZROTATE BASIC or EZROTATE LITE something like that...

Otherwise yeah try some maths "


Hi MrValentine, I finally decided to try EZ Rotate basic and SEEMS TO BE the final problem solver for the angles!.. I feel really fear to think about I win this battle but there are a lot of math calculations that EZRotate do in place of my poor and old brain!

I try some experiments and I will report the results!
Seems to be the Euler angles the solution!
For now Thank you!
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 28th Jan 2013 20:03
You can use matrices and vectors to get any angle without plugins.

*** Merry Chuckmas! ***
Le Verdier
14
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 28th Jan 2013 20:11
Using a plugin is a good solution, cause the angles conversion maths quite heavy in dbp..(I ve not tried this one, Idont know about its capabilities...)
As information, its something like this:

(!this code is not for YawPitchRoll, but the XYZ!)
I understand what you mean about the last angle...!
So using this requires to extract object rotation matrix...
But I think There is functions like this(I dont remember which ones) in IanM DLLs.. To avoid these heavy maths..

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 28th Jan 2013 20:23
If you using eXtendet rotations you can use
XROT PITCH TO(xrotMatResult, xrotMatObject, xrotVector, Angle#, flagGlobal) or XROT YAW TO(xrotMatResult, xrotMatObject, xrotVector, Angle#, flagGlobal) or XROT ROTATE TO(xrotMatResult, xrotMatObject, xrotVector, Angle#, Axis) to query a object matrix you can use DBOBJ GET ROTATION MATRIX(xrotMatResult, ObjectID)

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 28th Jan 2013 20:53 Edited at: 28th Jan 2013 20:54
Thank you all guys for help.
I tried EZRotate basic version but after some tests I am more confused than before..
Since now I got the Pitch and Roll angles finding the angle between 2 points.

@mr Handy thx and please can you provide me an example??

@Le Verdier, thx for code, you say it's not about YawPitchRoll but XYZ, however I will try it.

@MadBit, interesting, I will try this eXtendet rotations. I hope I can do something better than using EZRotate.. I am totally out of my experience and knowledge range
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 28th Jan 2013 21:00
I don't think this needs to be complicated or even needs pluggins. If you're trying to do some flying controls, you can use variables to hold the roll, pitch and yaw of the "aeroplane" use then standard TURN OBJECT, ROLL OBJECT and PITCH OBJECT commands.



As you can see, the trick is to set the orientation of the object back to zero then apply the rotations that you want.

I used this method for a twenty line challenge: http://forum.thegamecreators.com/?m=forum_view&t=195837&b=11. Theres an expanded version a few posts down.

one of these days I'll come up with a better signature
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 28th Jan 2013 21:12 Edited at: 28th Jan 2013 21:14
Quote: "I don't think this needs to be complicated or even needs pluggins. If you're trying to do some flying controls, you can use variables to hold the roll, pitch and yaw of the "aeroplane" use then standard TURN OBJECT, ROLL OBJECT and PITCH OBJECT commands.

+ Code Snippet

As you can see, the trick is to set the orientation of the object back to zero then apply the rotations that you want.

I used this method for a twenty line challenge: http://forum.thegamecreators.com/?m=forum_view&t=195837&b=11. Theres an expanded version a few posts down."


Hi, I can't use the TURN OBJECT/ROLL OBJECT/PITCH OBJECT commands I am using DarkDynamix physic to make my airplane surfing on thousand of darkDynamix air particles.

So I need just to obtain a method to find the ROLL PITCH and YAW values from the airplane angles

Can I use your code to obtain just the object ROLL PITCH and YAW (indipendent) angles??
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 28th Jan 2013 21:41
Hmm? I missed the bit where you said you were using dark dynamics. I've never used it myself and I've not used any other physics engines. From what I understand thoug, is that you apply forces to an object and then those forces affect the movement of the object. Is that correct?

In all honesty, I don't know the answer to this. I've had the same problems as you trying to unstand the way object angles "wrap" in the way you describe in your first post. The suggestion I posted was my answer to the issues I was having, so in a way I didn't answer your question.

Why do you need to the angles to be between 0 and 360 and what are you using them for? I ask this because we might be trying to solve the wrong problem. It might be easier to leave the angles as they are and use the values that are given by the OBJECT ANGLE X() etc commands.

one of these days I'll come up with a better signature
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 28th Jan 2013 21:49 Edited at: 28th Jan 2013 21:52
This is Evolved's automap, it contains matrix math, you can used math just as is.

The code checks object normal vector. In your case you just need to use your three vectors (axis) instead of normals.

Vectors, as angles, are: 0.0 for 0* ... 0.5 for 90* ... 1.0 for 180* (I suppose).




*** Merry Chuckmas! ***
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 28th Jan 2013 21:54
Dang it I keep forgetting eXtendet rotations thanks MadBit!

Le Verdier
14
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 28th Jan 2013 22:00
I had a look to the function I was talking about in IanM DLLs:
It is SET MATRIX4 TO OBJECT
There is also an equivalent to the code I give, but unfortunatly in XYZ order, not YPR....
I remember I spent hours and hours to calculate this function, wwithh the help of a TI89(a powerful calculator...)
Just a question:for what the angles are needed??
If info only, be careful this can be misleading due to gimbal lock
If other computation,I am sure there is another way via vectors or matrices..

Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 28th Jan 2013 22:44 Edited at: 28th Jan 2013 22:45
@29 games, hi, regard of the use of DarkDynamix, I just put my aircraft inside an air particles atmosphere zone where it is moving.
When my airplane change the angle of the tail surfaces so these surface start to make friction in the air particles and the plane start to roll, pitch and yaw.
Now. I just would to obtain the same variables all flight simulator provides : ACTUAL ROLL ANGLE, ACTUAL PITCH ANGLE and ACTUAL YAW ANGLE.
regardless DarkDynamix, I would just to know these values from the main airplane body objects.
I would to obtain these values in 360 degrees way just to handle these values more easly.



@mr Handy Thank you very much for code, I will test it, I am in serious difficulty just to exactly understand what I really want about these axes so your code is gold!



@MrValentine yeah, eXtendet rotations is another cartridge available! I will test it too!



@Le Verdier, I start to understand that the angles matter is damn damn COMPLEX...
I would just to know what is the ROLL, PITCH and YAW.. and I start to understand there is a damn bad difference between the rude XYZ axes......

The only little good thing is that If you calculate the angle between 2 points (in my case these two points are in the tips of my wings) you can know what is the ROLL inclination of the airplane. I not tested it too much but seems to be ok..... . Same thing for PITCH angle, calculating the angle between 2 points too (in my case these 2 points are the tip of the airplane nose and the end of the tail).

Maybe I can get the YAW inclination If I find a way to obtain a compass. Just calculating the difference between the new and the old compass angle...
Le Verdier
14
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 28th Jan 2013 23:14
Mathematicaly the difference consist in the order of the rotations
X axis, Y axis, Z axis
In aeronautics, YPR is used. The rotation sequence is reversed:
Z axis(R), Y axis(P), X axis(Y)
To have the same orientation

Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 28th Jan 2013 23:29
Quote: " The rotation sequence is reversed:
Z axis(R), Y axis(P), X axis(Y)
To have the same orientation"


mmm should be great if this mean that, for example, changing the X axis, other axes don't change their values...
But I doubt that..
Le Verdier
14
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 29th Jan 2013 18:57
1) I made a slight error in my last post, the correct rotation sequence is:
Z axis(R), X Axis(P), Y Axis(Y) considering global axis

2) I tried some plugins but unfortunatly with no good result at the end
EZ Rotate Basic: Not helpful for this problem
EXt Rotation: Doesnt work with me. after several attempts, my program freeze...
IanM Matrix1 (DLL #32) using the command i was counting on Set Matrix4 To Object: Give weird values and do not change..

Bug ??? maybe I am doing something wrong
If anyone could help.....

(At this state of dev, this code displays 2 objects. The rotation of left one can be changed with keys, and its transform matrix should have been displayed...)

From here Im quite annoyed. Difficult to progress without this working properly. (There is the workaround of rebuilding the matrix with angles but it is too much heavy, ineficient and all the drawbacks of the world..)

Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 29th Jan 2013 21:09 Edited at: 29th Jan 2013 21:11
.
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 29th Jan 2013 21:11 Edited at: 29th Jan 2013 21:14
Le Verdier really thanks for the effort you making for this topic!


In these 2 or 3 next days I will try some experiment and I will inform you of the results!



Ps. I tried your game (from your banner) and it's really cool!
If you add some extra effects, destruction and challengers, so you will obtain a damn great racing game!!!! Again compliments.
Le Verdier
14
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 30th Jan 2013 00:19
OK Feel free to tell me!

In the meantime if someone have info about the "Set Matrix4 To Object bug" please tell us!

I'm glad you liked my game but I put some info in its thread on how I move on

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 30th Jan 2013 09:15
Quote: "EXt Rotation: Doesnt work with me. after several attempts, my program freeze..."

Freeze the example's, too? If not. Maybe, you forgot to initialize XRot (XROT INITIALIZE) or forgot defining DXMatix and DXVectors?
Please see the Examples.

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Le Verdier
14
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 30th Jan 2013 12:58
I retried today and... my code works!??

The only thing I do since yesterday do is reboot my machine...




thanks for this plugin

This is a debug code i will use to tweak my AnglesFromMatrix4 function to obtain YawPitchRoll instead of XYZ...

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 30th Jan 2013 15:05
Then i am lucky.

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Le Verdier
14
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 30th Jan 2013 20:44
I found a solution faster than I though:



The "ship.dbo" is grabbed from my game..

At first glance, This code is not very spectacular.. 2 objects are displayed and the rotation is controlled by keys
The left one by according the standard DBP order, The right one with the converted to Yaw Pitch Roll Angles


Mathematicaly, the problem is identifying YPR values from this matrix:



Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 31st Jan 2013 09:19
Quote: "I found a solution faster than I though:

+ Code Snippet

The "ship.dbo" is grabbed from my game..

At first glance, This code is not very spectacular.. 2 objects are displayed and the rotation is controlled by keys
The left one by according the standard DBP order, The right one with the converted to Yaw Pitch Roll Angles


Mathematicaly, the problem is identifying YPR values from this matrix:

+ Code Snippet
"

Today I will install eXtendet rotations, I am really curious to test your code!
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 31st Jan 2013 11:15 Edited at: 31st Jan 2013 12:38
Quote: "I found a solution faster than I though:

+ Code Snippet

The "ship.dbo" is grabbed from my game..

At first glance, This code is not very spectacular.. 2 objects are displayed and the rotation is controlled by keys
The left one by according the standard DBP order, The right one with the converted to Yaw Pitch Roll Angles


Mathematicaly, the problem is identifying YPR values from this matrix:

+ Code Snippet
"

Today I will install eXtendet rotations, I am really curious to test your code!

EDIT: Hey mate seems your code working great!
I made not many tests but your ship roll,yaw and pitch are damn correct!
Thank you for the code and thanks to MadBit for eXtendRotation advice!


ps: sorry for doubled post..


EDIT:
A little (big?) mathematical question..:
If I would to convert your ROLL,YAW,PITCH values in the 360 degrees format?

I think this is possible but my math knowledge is laughing on my face..
Le Verdier
14
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 31st Jan 2013 18:02
Well.. Take all the time to test if all work ok...
Remember if other computations invo,ves angles, it's better to use vectors and matrices than angles values.
If displayed, remember the gimbal lock when pitch=+/-90..

Use Wrapvalue() function to convert to 0-360!

Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 31st Jan 2013 20:34
Really thanks Le Verdier! test time
MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 3rd Feb 2013 20:10
And take a look to the radar example .

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine

Login to post a reply

Server time is: 2026-07-07 00:49:11
Your offset time is: 2026-07-07 00:49:11