Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Ayumi), 662 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
vec_rotate() algorithm #352153
01/01/11 16:33
01/01/11 16:33
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Hi!

For a project, I made a visualisation of a vector calculation (with draw_line3d() etc.). Now I want to port the calculation to a micro controller. So I have to code all vec_...() functions for my own.
The problem is, that the vec_rotate() algorithm wasn't added to the manual. Does anybody know how to write a function that does something similar? I searched the internet, but it seems to be very difficult => a micro controller isn't that fast, so it should be something with less instructions.

Thanks for your help!


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: vec_rotate() algorithm [Re: Dark_samurai] #352156
01/01/11 16:50
01/01/11 16:50
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
i guess multiplying the vector with a rotation matrix would be easiest.

Re: vec_rotate() algorithm [Re: ventilator] #352159
01/01/11 17:09
01/01/11 17:09
Joined: Jun 2006
Posts: 379
Flevoland, 5 meters under wate...
Roel Offline
Senior Member
Roel  Offline
Senior Member

Joined: Jun 2006
Posts: 379
Flevoland, 5 meters under wate...
The rotation matrices would indeed be the easiest, and almost only way to do it.
and most microcontrollers have at least 1 MHz, so speed doesn't have to be a serious problem.


Check out the throwing game here: The throwing game
Re: vec_rotate() algorithm [Re: Roel] #352160
01/01/11 17:14
01/01/11 17:14
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Using quaternions is faster and more stable (no singularities known as gimbal lock) because even with the transformation overhead you need less operations (mul, add) compared to a full matrix multiplication with a vector!

Re: vec_rotate() algorithm [Re: HeelX] #352167
01/01/11 18:15
01/01/11 18:15
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Thanks for your fast replies!
I have no experience with quaternions or matrices... Could somebody give me an example that would be equal to that lite-c code, please?

Code:
ANGLE angTemp;
angTemp.pan = 0;
angTemp.tilt = -48;
angTemp.roll = 0;
vec_rotate(vecTemp, angTemp); //rotate vecTemp 48 degrees down



I also looked into some snippets about ratation matrices and it looks very slow (a lot of multiplication and angular functions)...


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: vec_rotate() algorithm [Re: Dark_samurai] #352171
01/01/11 19:13
01/01/11 19:13
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Are you doing arbitrary rotations or just on the XY, XZ or YZ plane?

Re: vec_rotate() algorithm [Re: HeelX] #352176
01/01/11 19:43
01/01/11 19:43
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
I'm only doing rotations by using the tilt. Does that answer your question?


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: vec_rotate() algorithm [Re: Dark_samurai] #352178
01/01/11 20:06
01/01/11 20:06
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
for 2d rotations you only need something like that:

x' = x cos f - y sin f
y' = y cos f + x sin f

Re: vec_rotate() algorithm [Re: ventilator] #352182
01/01/11 20:34
01/01/11 20:34
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Got it working laugh Thanks for the hint!


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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