floatsin, floatcos -
Cank - 25.05.2010
can someone explain me these two functions?
wiki doesnt help.
Re: floatsin, floatcos -
iJumbo - 25.05.2010
like this ??
Код:
new Float:x,Float:y,Float:z;
new Float:xx2,Float:yy2,Float:az;
new Float:x3,Float:y3;
new Float:x4,Float:y4;
new Float:x5,Float:y5;
new Float:x6,Float:y6;
new Float:xi,Float:yi;
new Float:xi2,Float:yi2;
if( strcmp(cmdtext, "/kame", true) == 0)
{
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid, az);
xi = x + (5 * floatsin(-az, degrees));
yi = y + (5 * floatcos(-az, degrees));
xx2 = x + (10 * floatsin(-az, degrees));
yy2 = y + (10 * floatcos(-az, degrees));
x3 = x + (15 * floatsin(-az, degrees));
y3 = y + (15 * floatcos(-az, degrees));
x4 = x + (20 * floatsin(-az, degrees));
y4 = y + (20 * floatcos(-az, degrees));
x5 = x + (25 * floatsin(-az, degrees));
y5 = y + (25 * floatcos(-az, degrees));
x6 = x + (30 * floatsin(-az, degrees));
y6 = y + (30 * floatcos(-az, degrees));
CreateExplosion(xi2,yi2,z-1,11,0);
CreateExplosion(xi,yi,z-1,11,2.5);
CreateExplosion(xx2,yy2,z-1,11,2.5);
CreateExplosion(x3,y3,z-1,11,2.5);
CreateExplosion(x4,y4,z-1,11,2.5);
CreateExplosion(x5,y5,z-1,11,2.5);
CreateExplosion(x6,y6,z-1,11,10);
return 1;
}
Re: floatsin, floatcos -
Cank - 25.05.2010
yes, but i dont understand how these functions work.
what are the parameters and what are these functions useful for?
Re: floatsin, floatcos -
[HiC]TheKiller - 25.05.2010
Well for a explanation on what sin, cos and tan actually are you can find it on wikipedia
http://en.wikipedia.org/wiki/Sin_cos_tan. That function pretty much makes the sin/cos/tan into a float value. Like 5235325.5523 =]. I'm not very good at Trigonometry so wait for a better answer =P.
Re: floatsin, floatcos -
Babul - 25.05.2010
these functions are useful for creating a circle. if you want a circle of cars at dry lake, then try this:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
//... start pasting the command from here
if (strcmp("/CarsDryLake", cmdtext, true) == 0)
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
for(new i = 0; i<360; i+=5)
{
new Float:CX,Float:CY,Float:CZ,Float:CA;
X=5.3426;
Y=1521.4684;
Z=12.7500;
CX=X+(40*floatsin(i,degrees));
CY=Y+(40*floatcos(i,degrees));
CZ=Z;
CA=(-i+180)%360;
CreateVehicle(412,CX,CY,CZ,CA,-1,-1,10);
}
SendClientMessage(playerid,0xafafff77,"Vehicle(s) spawned.");
return 1;
}
//... until here
}
X=5.3426 Y=1521.4684 Z=12.7500 << these are the coordinates at drylake. the "basis" position, its the middle point,
40*floatsin << the 40 is the radius (x-axis), the y-axis will be calculated with the floatcos,
if you want to create an ellipse, then modify one of those "40", maybe like:
CX=X+(50*floatsin(i,degrees));
CY=Y+(30*floatcos(i,degrees));
you can define how "dense" the cars are by the angle (degrees), its the 5 here:
for(new i = 0; i<360; i+=5) << set it to a lower value if you expand the circle to maybe 3 or 4 degrees
Re: floatsin, floatcos -
Cank - 25.05.2010
thanks