Board index FlightGear Development Weather

rand() Function in Nasal code  Topic is solved

Everything related to weather simulation, visuals should be discussed in the shader subforum.

rand() Function in Nasal code

Postby gierschi@flightgear » Wed Mar 09, 2016 12:22 pm

Hey guys,

I often find a function called rand() (e.g. in local_weather.nas). Where is it defined and what is the function doing? Maybe making something randomly?

Sebastian
gierschi@flightgear
 
Posts: 58
Joined: Tue Nov 03, 2015 10:40 pm

Re: rand() Function in Nasal code  

Postby sanhozay » Wed Mar 09, 2016 12:48 pm

It is a Nasal function defined in NasalSys.cxx: https://sourceforge.net/p/flightgear/fl ... salSys.cxx

This calls sg_random, which is defined in: https://sourceforge.net/p/flightgear/si ... g_random.c

As you can see from the comment on line 110, each call to it generates a random number between 0.0 and 1.0. So things like local weather will use it to randomly create clouds. Aircraft might use it to trigger things like failures, differences in fuel consumption between engines, slight differences in refuelling between tanks, etc.
sanhozay
 
Posts: 1207
Joined: Thu Dec 26, 2013 12:57 pm
Location: EGNM
Callsign: G-SHOZ
Version: Git
OS: Ubuntu 16.04

Re: rand() Function in Nasal code

Postby gierschi@flightgear » Wed Mar 09, 2016 2:08 pm

Great, thanks for the quick and helpful reply.
gierschi@flightgear
 
Posts: 58
Joined: Tue Nov 03, 2015 10:40 pm

Re: rand() Function in Nasal code

Postby Hooray » Wed Mar 09, 2016 8:21 pm

note that, at some point, there's been talk about another RNG for cloud placement to keep coud placement in sync between different instances, see Stuart's and Mathias' comments in the archives.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU


Return to Weather

Who is online

Users browsing this forum: No registered users and 3 guests