LYGIA Shader Library

rotateX (lygia/v1.1.4/space/rotateX)

rotate a 2D space by a radian angle

Dependencies:

Use:

rotateX(<vec3|vec4> pos, float radian [, vec3 center])

Check it on Github



#ifndef FNC_ROTATEX
#define FNC_ROTATEX
vec4 rotateX(in vec4 pos, in float radian, in vec4 center) {
    return rotate4dX(radian) * (pos - center) + center;
}

vec4 rotateX(in vec4 pos, in float radian) {
    #ifdef CENTER_4D
    return rotateX(pos, radian, CENTER_4D);
    #else
    return rotateX(pos, radian, vec4(.0));
    #endif
}

vec3 rotateX(in vec3 pos, in float radian, in vec3 center) {
    return (rotate4dX(radian) * vec4(pos - center, 1.)).xyz + center;
}

vec3 rotateX(in vec3 pos, in float radian) {
    #ifdef CENTER_3D
    return rotateX(pos, radian, CENTER_3D);
    #else
    return rotateX(pos, radian, vec3(.0));
    #endif
}
#endif

Dependencies:

Use:

rotateX(<float3|vec4> pos, float radian [, float3 center])

Check it on Github



#ifndef FNC_ROTATEX
#define FNC_ROTATEX
float3 rotateX(in float3 pos, in float radian, in float3 center) {
    return mul(rotate4dX(radian), vec4(pos - center, 1.)).xyz + center;
}

float3 rotateX(in float3 pos, in float radian) {
    #ifdef CENTER_3D
    return rotateX(pos, radian, CENTER_3D);
    #else
    return rotateX(pos, radian, float3(0.0, 0.0, 0.0));
    #endif
}
#endif

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository