Advanced math help required.
#2

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
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;
}
If you want 15 dots now you should use it like (same as your example)
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);
}
Reply


Messages In This Thread
Advanced math help required. - by zaibaslr2 - 24.01.2015, 14:55
AW: Advanced math help required. - by Nero_3D - 24.01.2015, 17:05
Re: Advanced math help required. - by codectile - 24.01.2015, 17:12
Re: Advanced math help required. - by Write - 24.01.2015, 17:22
Re: Advanced math help required. - by zaibaslr2 - 24.01.2015, 17:22

Forum Jump:


Users browsing this thread: 1 Guest(s)