24.01.2015, 17:05
You only need to know the center of your circle and your first point
That function rotates that point by the given angle around the center
If you want 15 dots now you should use it like (same as your example)
That function rotates that point by the given angle around the center
pawn Код:
stock GetNextPointOnCircle(Float: cX, Float: cY, & Float: X, & Float: Y, Float: angle, const amode = degrees) {
new
Float: cos = floatcos(angle, amode),
Float: sin = floatsin(angle, amode),
Float: tX = X - cX,
Float: tY = Y - cY
; // source - en.wikipedia.org/wiki/Rotation_matrix
X = tX * cos - tY * sin + cX;
Y = tX * sin + tY * cos + cY;
}
pawn Код:
new
dots = 15,
Float: cX = 6.0, // center of circle
Float: cY = 4.0, // center of circle
Float: X = 6.0, // first point
Float: Y = 1.0, // first point
Float: angle = 360.0 / dots // split the circle in x (dots) pieces
;
while(dots--) { // crashes your server if dots < 0
GetNextPointOnCircle(cX, cY, X, Y, angle);
printf("%f %f", X, Y);
}