Well..... this is a Geometry question but it's connected to scripting =D
Big thanks to
zeroibis. I'm currently using one of his stocks. To make a circle laser (Different from TE_SetupBeamRing(Point)). Note that the PI already defined 3.1415926535897932384626433832795
PHP Code:
/*
* DRAW A VERTICAL CIRCLE
*
* NOTE MUST PLACE OnMapStart_Circle() in OnMapStart of program to use
*
* @param Float:vecLocation[3] Location of circle.
* @param Float:radius Radius of circle.
*/
stock Circle(Float:vecLocation[3], Float:radius)
{
new Float:angle=0.0, Float:x, Float:y;
new Float:pos1[3];
new Float:pos2[3];
//Create the start position for the first part of the beam
pos2[0] = vecLocation[0];
pos2[1] = vecLocation[1] + radius;
pos2[2] = vecLocation[2];
while (angle <= 2 * PI)
{
x = radius * Cosine(angle);
y = radius * Sine(angle);
pos1[0] = vecLocation[0];
pos1[1] = vecLocation[1] + x;
pos1[2] = vecLocation[2] + y;
TE_SetupBeamPoints(pos1, pos2, BeamSpriteCircle, HaloSpriteCircle, 0, 0, 8.0, Float:5.0, Float:5.0, 5, 0.0, {255,255,255,255}, 3);
TE_SendToAll();
pos2[0] = pos1[0];
pos2[1] = pos1[1];
pos2[2] = pos1[2];
angle += 0.7;
}
}
I'm currently want to make 20 entities arranged in a half circle shape by learning out of this stock. But I haven't learn much in Geometry in school. So what actually this loop do?
PHP Code:
while (angle <= 2 * PI)
{
x = radius * Cosine(angle);
y = radius * Sine(angle);
pos1[0] = vecLocation[0];
pos1[1] = vecLocation[1] + x;
pos1[2] = vecLocation[2] + y;
TE_SetupBeamPoints(pos1, pos2, BeamSpriteCircle, HaloSpriteCircle, 0, 0, 8.0, Float:5.0, Float:5.0, 5, 0.0, {255,255,255,255}, 3);
TE_SendToAll();
pos2[0] = pos1[0];
pos2[1] = pos1[1];
pos2[2] = pos1[2];
angle += 0.7;
}
I is pretty sure that this loops creates a very short beams what is looped until it reach a circle. But I don't understand how. I thought Trigonometry is to calculate Triangle Angles or the ratio of two sides of a triangle. What does it do with a circle?? Or maybe you can explain what this whole loop do? ^^
Thanks for readin
__________________