Glm::rotate and glm::angle

Hi, I would like to create a function that creates a vec2 object from an angle. Much like the proccessing function vector.fromAngle()

The idea is angVec (float _angle) function that creates the vec2 object.

//cpp
angVec (float _angle){
float ang = _angle;
vec2 vec;
glm::rotate(vec, angle);
vecAng = glm::angle(vec) // return the angle for other purposes
}

Im struggling with the correct syntax for glm to make this work.
Perhaps this func already exists, any help much appreciated.
Chris

here is a link to the same question, but I wanted to do it in glm.
vec2f

    glm::vec2 test(1, 0);
    auto result = glm::rotate(test, glm::radians(90.0f));
    cout << " vec is now " << result << endl;

this should work as requested :slight_smile:

1 Like