Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 10:32
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (AndrewAMD, alibaba, fairtrader, ozgur, TipmyPip, Quad), 604 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
HELP: Angle Problem #205286
05/05/08 16:14
05/05/08 16:14
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
Hello.

I have this 2 action:

action rotate_ent1{
var p1;

while(1){
my.pan+=1*time;
p1=my.pan; // p1 stores this pan.
wait(1);}
}

action rotate_ent2{
var p2;

while(1){
ang_rotate(my.pan,vector(1,0,0)); // adding the sameway pan guess
p2=my.pan; // p1 stores this pan.
wait(1);}
}

THEN i have a panel, showing p1 and p2.. Now my problem is that, on ent 1 the pan will go from zero to 260 .. 450 etc etc..
and the p2 will go to 179 then.. turn -179..-150 .. -120. etc.. the other way .. Why?

Now if i have to points, and the angle p1 is 180 calculated from p2 , i want p2 to face p1, then a do c_rotate(me,vector(0.1,0,0),USE_AXISr|GLIDE); if the angle is < p1 but each time is turn 180 it will go negative other way, and my entity will rotate like a snake, right , left, right left, and can''t figure out this...
I want to do a c_rotate(me,vector(0.1,0,0),USE_AXIS|GLIDE); and i can't because when it reaches the 180 degree, it will be counting back negative, thus confusing the if angle < angle target calculation, since if its not < it will be > and will c rotate the other way.. and never reach the right angle.

Last edited by MMike; 05/05/08 16:16.
Re: HELP: Angle Problem [Re: MMike] #205290
05/05/08 16:54
05/05/08 16:54
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
why does c_rotate or ang_add will turn my.pan just range from -180 to 180 ?

With further tests, i got this:


X------------->O


35999º
X------------->O

You can point 0º or 360º its the same, but.. for the entity its not, since with 360º it will need to go back till 0º is reached, and will give a full rotation.

Now imagine this:
You have the angle between p1(me) and p2(target) which is 20º ( calculated from vec_to_angle positions).

The my pan is 180º more from the target, so they are not facing each other.
How do you turn to your target, add the angle or will reduce the angle so it reachs 20º and face the target? you could also add more, and it would be the same..
The problem is that when you turn, new calculations are made, and suddenty it says the angle is not 20º but 20-360º now, the entity will turn the other side, and over and over, and won't work.




<--X(me) O(target)


Last edited by MMike; 05/05/08 18:01.
Re: HELP: Angle Problem [Re: MMike] #206774
05/15/08 17:05
05/15/08 17:05
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States


xXxGuitar511
- Programmer

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