November 26 2024 10:26:40
Navigation
· Home
· Articles
· Downloads
· FAQ
· Discussion Forum
· Web Links
· News Categories
· Contact Me
· Photo Gallery
· Search
· Gameservers
Languages
Users Online
· Guests Online: 16

· Members Online: 0

· Total Members: 1,134
· Newest Member: Brody
Teamspeak 3
Last Seen Users
· hackepter01:08:47
· GONZO18:03:18
· Intruder18:30:01
· Sully 1 day
· desintegrator 2 days
· WEZ 3 days
· Homi 3 days
· The ACE 4 days
· xhc 1 week
· dRgiGGLeZ 1 week
· El Dookie 1 week
· Melber 2 weeks
· SGT PEPPER 2 weeks
· martyr 2 weeks
· Terminator 2 weeks

View Thread: Randomized vector
Vietcong.Info » Vietcong General Discussion » Maps & Mapping
Who is here? 1 Guest
Current Rating: (Total: 0 ratings)  
 Print Thread
Randomized vector
KostiCZ
Can anybody help me with maybe simple task? I have vector and I need to modify it by random number, each axis by +-5%. But I'm making something wrong - rnd number is still 0. So question is how to define random number generation?

rndpom = (SRV_Random(100) - 50)/50;
vec.x = vec.x * rndpom;

I tried also

vec.x = vec.x + vec.x * rndpom;

After that the vector is not changed. Can somebody help?
Signature________________________________________________

2LT William Theolinus "KostiCZ" Boner Jr.
LRRP Squad Baker, Delta Team
cache.www.gametracker.com/player/KostiCZ/63.143.47.189:2302/b_560x95.png
 
Teamrespawn.cz
Ando
Are you talking about vietcong scripts?
If yes then
random integer number:
int rand(void);
my_random_int = rand() % max_num;


random float number:
float frnd(float max);
my_random_float = frnd(max_num);


EDIT:
here is example code for random +/- 5 degrees
Download source  Code
#define    max_angle   5 // max angle in degrees



vec.x=-DEG_TO_RAD(max_angle)+frnd(DEG_TO_RAD(max_angle*2));


Edited by Ando on 10-03-2012 22:59
  x 1  x 1
 
Jump to Forum:
Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Render time: 0.17 seconds - 50 Queries 5,473,108 unique visits