LYGIA Shader Library

scale4d (lygia/math/scale4d)

returns a 4x4 scale matrix

Use:

<mat4> scale4d(<float|vec3|vec4> radians)
<mat4> scale4d(<float> x, <float> y, <float> z [, <float> w])

Check it on Github


#ifndef FNC_SCALE4D
mat4 scale4d(float s) {
    return mat4(s, 0.0, 0.0, 0.0,
                0.0, s, 0.0, 0.0,
                0.0, 0.0, s, 0.0,
                0.0, 0.0, 0.0, 1.0 );
}

mat4 scale4d(float x, float y, float z) {
    return mat4( x, 0.0, 0.0, 0.0,
                0.0,  y, 0.0, 0.0,
                0.0, 0.0,  z, 0.0,
                0.0, 0.0, 0.0, 1.0);
}

mat4 scale4d(float x, float y, float z, float w) {
    return mat4( x, 0.0, 0.0, 0.0,
                0.0,  y, 0.0, 0.0,
                0.0, 0.0,  z, 0.0,
                0.0, 0.0, 0.0,  w );
}

mat4 scale4d(vec3 s) {
    return mat4(s.x, 0.0, 0.0, 0.0,
                0.0, s.y, 0.0, 0.0,
                0.0, 0.0, s.z, 0.0,
                0.0, 0.0, 0.0, 1.0 );
}

mat4 scale4d(vec4 s) {
    return mat4(s.x, 0.0, 0.0, 0.0,
                0.0, s.y, 0.0, 0.0,
                0.0, 0.0, s.z, 0.0,
                0.0, 0.0, 0.0, s.w );
}
#endif

Use:

<float4x4> scale4d(<float|float3|float4> radians)
<float4x4> scale4d(<float> x, <float> y, <float> z [, <float> w])

Check it on Github


#ifndef FNC_SCALE4D
float4x4 scale4d(float s) {
    return float4x4(s, 0.0, 0.0, 0.0,
                0.0, s, 0.0, 0.0,
                0.0, 0.0, s, 0.0,
                0.0, 0.0, 0.0, 1.0 );
}

float4x4 scale4d(float x, float y, float z) {
    return float4x4( x, 0.0, 0.0, 0.0,
                0.0,  y, 0.0, 0.0,
                0.0, 0.0,  z, 0.0,
                0.0, 0.0, 0.0, 1.0);
}

float4x4 scale4d(float x, float y, float z, float w) {
    return float4x4( x, 0.0, 0.0, 0.0,
                0.0,  y, 0.0, 0.0,
                0.0, 0.0,  z, 0.0,
                0.0, 0.0, 0.0,  w );
}

float4x4 scale4d(float3 s) {
    return float4x4(s.x, 0.0, 0.0, 0.0,
                0.0, s.y, 0.0, 0.0,
                0.0, 0.0, s.z, 0.0,
                0.0, 0.0, 0.0, 1.0 );
}

float4x4 scale4d(float4 s) {
    return float4x4(s.x, 0.0, 0.0, 0.0,
                0.0, s.y, 0.0, 0.0,
                0.0, 0.0, s.z, 0.0,
                0.0, 0.0, 0.0, s.w );
}
#endif

Use:

<matrix<float, 4, 4>> scale4d(<float|float3|float4> radians)
<matrix<float, 4, 4>> scale4d(<float> x, <float> y, <float> z [, <float> w])

Check it on Github


#ifndef FNC_SCALE4D
matrix<float, 4, 4> scale4d(float s) {
    return matrix<float, 4, 4>(s, 0.0, 0.0, 0.0,
                0.0, s, 0.0, 0.0,
                0.0, 0.0, s, 0.0,
                0.0, 0.0, 0.0, 1.0 );
}

matrix<float, 4, 4> scale4d(float x, float y, float z) {
    return matrix<float, 4, 4>( x, 0.0, 0.0, 0.0,
                0.0,  y, 0.0, 0.0,
                0.0, 0.0,  z, 0.0,
                0.0, 0.0, 0.0, 1.0);
}

matrix<float, 4, 4> scale4d(float x, float y, float z, float w) {
    return matrix<float, 4, 4>( x, 0.0, 0.0, 0.0,
                0.0,  y, 0.0, 0.0,
                0.0, 0.0,  z, 0.0,
                0.0, 0.0, 0.0,  w );
}

matrix<float, 4, 4> scale4d(float3 s) {
    return matrix<float, 4, 4>(s.x, 0.0, 0.0, 0.0,
                0.0, s.y, 0.0, 0.0,
                0.0, 0.0, s.z, 0.0,
                0.0, 0.0, 0.0, 1.0 );
}

matrix<float, 4, 4> scale4d(float4 s) {
    return matrix<float, 4, 4>(s.x, 0.0, 0.0, 0.0,
                0.0, s.y, 0.0, 0.0,
                0.0, 0.0, s.z, 0.0,
                0.0, 0.0, 0.0, s.w );
}
#endif

Check it on Github


fn scale4d(s: vec3f) -> mat4x4<f32> {
    return mat4x4<f32>( s.x, 0.0, 0.0, 0.0,
                        0.0, s.y, 0.0, 0.0,
                        0.0, 0.0, s.z, 0.0,
                        0.0, 0.0, 0.0, 1.0);
}

Licenses

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