How to do this?
#7

Quote:
Originally Posted by akib
Посмотреть сообщение
This code isn't working for me :/ it creates object outside of the circle...

if the center is 2814.9570,1313.2760,10.7500
and it's X Y is 2814.9570,1313.2760 then

Код:
Float:frandom(Float:max, Float:min = 0.0, dp = 4)//made by ******
{
    new Float:mul = floatpower(10.0, dp),

    imin = floatround(min * mul),
    imax = floatround(max * mul);
    return float(random(imax - imin) + imin) / mul;
}

COMMAND:fireup(playerid,params[]){
	new Float:centerX = 2814.9570;//center of the circle
	new Float:centerY = 1313.2760;//center of the circle

	new Float:radius = 3.0;//radius of the circle
	for(new i=0;i<8;i++){
		new Float:rrandom = frandom(0, 6.28);
		new Float: px = centerX/2+floatcos(rrandom,degrees)*radius;
		new Float: py = centerY/2+floatsin(rrandom,degrees)*radius;
		CreateObject(18688, px,py, 10.7500,0,0,0,300.0);
		printf("%f,%f",px,py);
	}
	//2814.9570,1313.2760,10.7500
	return 1;
}
and results:
Код:
1408.816772,658.124267
1406.247192,655.061950
1405.515258,657.019592
1408.596923,658.296081
1409.357910,657.322021
1406.039794,655.248657
1409.434814,657.053833
1407.825805,654.668395
Like niCe said, those angle calculations are in degrees, so instead of 6.28 you should use 360.0, otherwise the objects will only get spread between 0° and 6.28°.

Oh and remove the /2 from centerX and centerY, it's not neccessary. This already explains why the results are only half of your original coords.
Reply


Messages In This Thread
How to do this? - by akib - 27.11.2018, 14:56
Re: How to do this? - by Rolux - 27.11.2018, 15:30
Re: How to do this? - by akib - 28.11.2018, 00:49
Re: How to do this? - by niCe - 28.11.2018, 01:02
Re: How to do this? - by akib - 28.11.2018, 03:21
Re: How to do this? - by m4karow - 28.11.2018, 09:40
Re: How to do this? - by NaS - 28.11.2018, 16:32
Re: How to do this? - by akib - 29.11.2018, 00:11

Forum Jump:


Users browsing this thread: 1 Guest(s)