lundi 8 juillet 2019

rotating a 2d circle function

im trying to add rotate to my function.

I have no idea how i can rotate it in my function

void draw_filled_circle(const RenderListPtr& render_list, const Vec2& position, float radius, CircleType type, Color color, float rotate){
    float pi;
    if (type == FULL) pi = D3DX_PI;         // Full circle
    if (type == HALF) pi = D3DX_PI / 2;     // 1/2 circle
    if (type == QUARTER) pi = D3DX_PI / 4;  // 1/4 circle

    const int segments = 32;
    float angle = rotate * D3DX_PI / 180;
    Vertex v[segments + 1];

    for (int i = 0; i <= segments; i++){
        float theta = 2.f * pi * static_cast<float>(i) / static_cast<float>(segments);
        v[i] = Vertex{
            position.x + radius * std::cos(theta),
            position.y + radius * std::sin(theta),
            color
        };
    }
    add_vertices(render_list, v, D3DPT_TRIANGLEFAN);
}

Aucun commentaire:

Enregistrer un commentaire