Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (blaurock), 750 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Simple but annoying Bug VEC_ROTATE #397131
03/14/12 21:13
03/14/12 21:13
Joined: Jan 2009
Posts: 78
always overseas
S
SeaCancer Offline OP
Junior Member
SeaCancer  Offline OP
Junior Member
S

Joined: Jan 2009
Posts: 78
always overseas
today I found very simple but very annoying Bug,,

It is related to the:
vec_rotate (VECTOR* vDir, ANGLE* vAng)

this function is useful in many programming issues like camera and movement vectors

However, this function is not giving correct results if the vector that you want to rotate is not aligned to the axis

i.e: vector (10,10,10) if you want to rotate it around the origin by angles 90,45,0

you will have very funny results that are totally wrong at all

so try to avoid this function now
also:
ang_rotate

same error!

It only gives right results if you want to rotate a vector that is aligned to the xyz axis, like vector (10,0,70)

or if you rotate a vector without changing the tilt componant
i.e rotate vector (10,10,10) using the angles (90,0,0)
this will work (only accept pan angle)

Last edited by SeaCancer; 03/14/12 21:20.
Re: Simple but annoying Bug VEC_ROTATE [Re: SeaCancer] #397138
03/15/12 00:52
03/15/12 00:52
Joined: Jan 2009
Posts: 78
always overseas
S
SeaCancer Offline OP
Junior Member
SeaCancer  Offline OP
Junior Member
S

Joined: Jan 2009
Posts: 78
always overseas
I got the problem clearly now laugh

if you have a vector not aligned to the xyz axis
example camera_dir (10,20,30)

Now, if you want vec_rotate to rotate this vector by a "tilt" angle only, it will destroy the "pan" angle that you do not want to change

and if you want vec_rotate to rotate a vector by a pan angle & tilt, here is the disaster laugh

Re: Simple but annoying Bug VEC_ROTATE [Re: SeaCancer] #397140
03/15/12 04:46
03/15/12 04:46
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
You still arent being clear (to me at least) with what you are trying to achieve.

There are many different vector/angle manipulation functions, and I suspect you
just need to find the 'right' one, which isnt always easy.
OR there is a chance that you are hitting the dreaded 'gimbal lock' issue.
If vec_rotate was ACTUALLY bugged, it would be affecting a great many people...

Can you give a few SIMPLE examples of what results you are expecting...
eg:
(10,10,10) + (0,15,0) = (10,25,10)
(20,20,20) + (15,20,25) = (35,40,45)
and the like...




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Simple but annoying Bug VEC_ROTATE [Re: EvilSOB] #397152
03/15/12 14:44
03/15/12 14:44
Joined: Jan 2009
Posts: 78
always overseas
S
SeaCancer Offline OP
Junior Member
SeaCancer  Offline OP
Junior Member
S

Joined: Jan 2009
Posts: 78
always overseas
ok, i will write a simple code in no time laugh

Re: Simple but annoying Bug VEC_ROTATE [Re: SeaCancer] #397153
03/15/12 14:56
03/15/12 14:56
Joined: Jan 2009
Posts: 78
always overseas
S
SeaCancer Offline OP
Junior Member
SeaCancer  Offline OP
Junior Member
S

Joined: Jan 2009
Posts: 78
always overseas
here we go:

ANGLE test;

function EvilSOB ()
{
var vectot_test [3];
vec_set (vectot_test,vector (10,10,10));
vec_rotate (vectot_test, vector(0,0,0)); // rotation angles change here
vec_to_angle (test,vectot_test);
}

just put the angle test as "watched" variable, you can see that the angles of this vector is (45,35.26,0), this is 100% right

Now let us rotate it another 45 pan:
the result is (90,35.26,0), this is 100% right too laugh

NOW, let us rotate it 30 pan and 10 tilt just change the rotation angles to 30,10,0 in the code
the result is: 81,42,0 this is totally wrong!
the right values are (75,45.26,0)

NOW, let us rotate it 10 tilt just change the rotation angles to 0,10,0 in the code
the result is: 51,42,0 this is totally wrong!
the right values are (45,45.26,0)

So, the calculations of tilt are affecting the pan and vice versa






Last edited by SeaCancer; 03/15/12 14:57.
Re: Simple but annoying Bug VEC_ROTATE [Re: SeaCancer] #397154
03/15/12 15:03
03/15/12 15:03
Joined: Jan 2009
Posts: 78
always overseas
S
SeaCancer Offline OP
Junior Member
SeaCancer  Offline OP
Junior Member
S

Joined: Jan 2009
Posts: 78
always overseas
Ops, I forgot to say that ang_rotate will do the same error

Re: Simple but annoying Bug VEC_ROTATE [Re: SeaCancer] #397160
03/15/12 21:07
03/15/12 21:07
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
In a 3 dimensional rotation, rotating a vector changes all angles unless in special cases when the vector had only one nonzero coordinate. Look for "Euler angles" the manual, there you find how a 3D rotation is defined. vec_rotate has certainly no bug, this is just normal math. I dont know what you want to do but maybe you want a relative rotation and not a absolute? You need ang_add then. Look in the manual for examples.

For your own safety I move this out of the bug forum laugh - people use vec_rotate a thousand times since 10 years all in their projects and would kill you if it suddenly behaved different and all the projects would not work anymore.

Re: Simple but annoying Bug VEC_ROTATE [Re: Tobias] #397163
03/15/12 21:39
03/15/12 21:39
Joined: Jul 2007
Posts: 424
EUROPE
maslone1 Offline
Senior Member
maslone1  Offline
Senior Member

Joined: Jul 2007
Posts: 424
EUROPE
Don't say `kill` :-) . Just terminate :-)


A8c, Blender, FlStudio, Unity3d
Re: Simple but annoying Bug VEC_ROTATE [Re: maslone1] #398025
03/26/12 15:35
03/26/12 15:35
Joined: Jan 2009
Posts: 78
always overseas
S
SeaCancer Offline OP
Junior Member
SeaCancer  Offline OP
Junior Member
S

Joined: Jan 2009
Posts: 78
always overseas
Hi Tobias, Hi maslone1


ang_add did the same frown

my background in math is good, look I will tell you something, Just try it:

set a vector to the value of: (10,10,10);
by logic the absolute pan is 45 and the tilt is 35.26

NOW, rotate it 30 pan and 10 tilt
the new angles will be: 81,42,0 this is totally wrong!

OR:
asume that I want to increase the tilt only, to rise the camera as example, VEC_ROTATE will change my pan,, why?? I want the pan angle fixed

I solved this issue by adding 2-3 lines of code, but I am writting this for other users
the right values are (75,45.26,0)


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1