# LYGIA Shader Library

## rotateX (`lygia`/`space`/`rotateX`)

rotate a 2D space by a radian angle

Dependencies:

Use:

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

Check it on Github

``````

#ifndef FNC_ROTATEX
#define FNC_ROTATEX
vec4 rotateX(in vec4 v, in float r, in vec4 c) {
return rotate4dX(r) * (v - c) + c;
}

vec4 rotateX(in vec4 v, in float r) {
#ifdef CENTER_4D
return rotate4dX(r) * (v - CENTER_4D) + CENTER_4D;
#else
return rotate4dX(r) * v;
#endif
}

vec3 rotateX(in vec3 v, in float r, in vec3 c) {
return (rotate4dX(r) * vec4(v - c, 1.0)).xyz + c;
}

vec3 rotateX(in vec3 v, in float r) {
#ifdef CENTER_3D
return (rotate4dX(r) * vec4(v - CENTER_3D, 1.0)).xyz + CENTER_3D;
#else
return (rotate4dX(r) * vec4(v, 1.0)).xyz;
#endif
}
#endif

``````

Dependencies:

Use:

``````rotateX(<float3|float4> 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), float4(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

``````