rotation_ in gWinZone.cpp - standing sinus wave

What do you want to see in Armagetron soon? Any new feature ideas? Let's ponder these ground breaking ideas...
Post Reply
name
Posts: 8
Joined: Mon Mar 17, 2008 1:57 pm

rotation_ in gWinZone.cpp - standing sinus wave

Post by name »

Hi,

didnt know where to put this. I wanted to know how the rotation_ in gWinZone.cpp is defined, because I need to substract the rotation factor from a sinus function to create some kind of standing sinus wave. It would be nice if someone can explain me how the rotation actually works or just tell me the factor in gZone::render() which rotates the zone each time.

It already works partially if I subtract the acos() of rotation_.x in the sinus function - first a standing wave is created - then probably after a half or a full rotation the wave is moving as long as it was standing first - it seems that this happens because of a prefix problem (first it substracts the (correct) rotation factor then it adds the factor whichs results in a change between standing and moving wave) - i also tried in several ways to get the absolute value with fabs() but it didnt changed anything.

(sorry for my bad english - i hope you could understand my problem)
best regards
name
User avatar
Z-Man
God & Project Admin
Posts: 11717
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

it's this line in gZone::Timestep():

Code: Select all

rotation_ = rotation_.Turn( cos( angle ), sin( angle ) );
Your problems with acos would come from the fact that the cos function is not globally invertible and acos only is its inverse in a small area; it's what adds the perceived offset (really it's more of a reversal).
name
Posts: 8
Joined: Mon Mar 17, 2008 1:57 pm

Post by name »

So it would probably work if i substract directly the angle that is defined there. I already tried this way, but i failed at getting the time var into the render function
User avatar
Z-Man
God & Project Admin
Posts: 11717
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

The time of the last update is always available in the lastTime member variable.
name
Posts: 8
Joined: Mon Mar 17, 2008 1:57 pm

Post by name »

Ah, thanks - it seems to be solved.

Code: Select all

REAL angle = ( lastTime - createTime_ ) * speed;
Post Reply