Git Product home page Git Product logo

gl3n's People

Contributors

benjones avatar bioinfornatics avatar brad-anderson avatar coldencullen avatar cromfr avatar dav1dde avatar dayllenger avatar drinfiniteexplorer avatar fr3nchk1ss avatar holtrop avatar john-colvin avatar kiith-sa avatar lcodes avatar martinnowak avatar mathstuf avatar p0nce avatar s-ludwig avatar serialvelocity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gl3n's Issues

1x1 matrices

Hello again!

When you create a 1 by 1 matrix the invert() function complains...

Matrix!(float, 1, 1) M;

Note: I'm not actually explicitly creating a 1 by 1 matrix since that would be silly, but it comes up as the result of multiplying multiple matrices together.

Broke in dmd 2.068.0

Every time I want to compile something with gl3n as dependency now it spams the console with
dub\packages\gl3n-1.1.0\gl3n\linalg.d(425): Warning: int /= real is performing truncating conversion
and then stops compilation.

Tested on windows (gl3n 1.0.1 and 1.1.0) and on linux (1.0.1)

'TypeTuple' not found and other stuff

../../../../../.dub/packages/dlib-0.7.1/dlib/filesystem/stdfs.d(34,8): Deprecation: module std.c.stdio is deprecated - Import core.stdc.stdio instead
dlib.container.aarray is deprecated, use dlib.container.dict instead
../../../../../.dub/packages/dlib-0.7.1/dlib/geometry/ray.d(46,5): Deprecation: constructor dlib.geometry.ray.Ray.this all parameters have default arguments, but structs cannot have default constructors.
../../../../../.dub/packages/dlib-0.7.1/dlib/filesystem/posix/file.d(53,17): Deprecation: package core.sys is not accessible here
../../../../../.dub/packages/dlib-0.7.1/dlib/filesystem/posix/file.d(53,21): Deprecation: package core.sys.posix is not accessible here
../../../../../.dub/packages/dlib-0.7.1/dlib/filesystem/posix/file.d(53,27): Deprecation: module core.sys.posix.unistd is not accessible here, perhaps add 'static import core.sys.posix.unistd;'
../../../../../.dub/packages/dlib-0.7.1/dlib/filesystem/posix/file.d(88,36): Deprecation: package core.sys is not accessible here
../../../../../.dub/packages/dlib-0.7.1/dlib/filesystem/posix/file.d(88,40): Deprecation: package core.sys.posix is not accessible here
../../../../../.dub/packages/dlib-0.7.1/dlib/filesystem/posix/file.d(88,46): Deprecation: module core.sys.posix.unistd is not accessible here, perhaps add 'static import core.sys.posix.unistd;'
../../../../../.dub/packages/dlib-0.7.1/dlib/filesystem/posix/file.d(101,20): Deprecation: package core.sys is not accessible here
../../../../../.dub/packages/dlib-0.7.1/dlib/filesystem/posix/file.d(101,24): Deprecation: package core.sys.posix is not accessible here
../../../../../.dub/packages/dlib-0.7.1/dlib/filesystem/posix/file.d(101,30): Deprecation: module core.sys.posix.unistd is not accessible here, perhaps add 'static import core.sys.posix.unistd;'
gl3n 1.2.0: building configuration "library"...
../../../../../.dub/packages/gl3n-1.2.0/gl3n/util.d(14,12): Error: module std.typecons import 'TypeTuple' not found, did you mean template 'isTypeTuple(T...)'?
dmd failed with exit code 1.
Joels-MacBook-Pro:Joel joelcnz$

Initial release

Please could you make an initial release, "v0.1.0" perhaps, to fit in with dub's deprecation of git branch support (e.g. "~master").

Cheers.

Compile error in chained operations

Fails with GDC 2.064.2. Other compilers untested.

private import gl3n.linalg;

int main(string[] args) {
  vec3 pos = vec3(1, 1, 1);
  vec3 size = vec3(1, 1, 1);
  vec3 of = vec3(1, 1, 1);

  //vec3 fails = pos + size * of;

  vec3 inter = size * of;
  vec3 works = pos + inter;

  return 0;
}
t.d:9: error: incompatible types for ((pos) + (size.opBinary(of))): 'Vector!(float, 3)' and 'float'

Matrix look_at optimization

Thought I'd just make a few optimization reports when I find them. Here's the one from Bitbucket:

static auto look_at(Vector!(mt, 3) eye, Vector!(mt, 3) target, Vector!(mt, 3) up) {
    auto look_dir = (target - eye).normalized;
    auto right_dir = cross(look_dir, up).normalized;
    auto perp_up_dir = cross(right_dir, look_dir);

    auto ret = Matrix.identity;

    // rotate
    ret.matrix[0][0..3] = right_dir.vector;
    ret.matrix[1][0..3] = perp_up_dir.vector;
    ret.matrix[2][0..3] = (-look_dir).vector;

    // translate
    ret.matrix[0][3] = eye.dot(-perp_up_dir.vector);
    ret.matrix[1][3] = eye.dot(-right_dir.vector);
    ret.matrix[2][3] = eye.dot(look_dir.vector);

    return ret;
}

Remove testing perspective function

I strongly believe that "static Matrix perspective(mt width, mt height, mt fov = 60.0, mt near = 1.0, mt far = 100.0)" should be removed.

I don't see the reason for its existence (it seems like a testing function to me, so should be hidden from the api) and because of the default parameters it can cause massive confusion if one believes that the functionality is similar to that of glm's perceptive function.

i.e. I called perspective(fov, ratio, near, far) and it silently worked, but did completely the wrong thing.

I'll submit a patch to this affect later if it help, and thanks for the great work.

Fix site

The github hosted site currently has some errors such as missing or unstyled pages.

Transformation call order

Hey, I'm just wondering if i'm doing something wrong if i need to write all my transformation calls backwards for example:

mat4.identity.rotatey(roty).rotatex(rotx).translate(x, y, z)

When I read the documentation for gl3n you write it in this order.

mat4.identity.translate(x, y, z).rotatex(rotx).rotatey(roty);

And other example is:

This does not work

mat4.identity.translate(x, y, z);
// Which is the same as
mat4.translation(x, y z) * mat4.identity;

This does work

mat4.identity * mat4.translation(x, y z);

Am I doing something wrong or is this a bug?

I am using ldc (which is the default for dub)

Transposed matrixes not supported on every system

Hello,

i am currently writing a rpg engine in D. I recently ran into a confusing problem caused by the following:

In older OpenGL versions, especially when you only have access to ES Core 2.0 contexts, glUniformMatrix only accepts GL_FALSE as transpose argument and otherwise generates a GL_INVALID_VALUE [1]. While i can simply call transpose() on the matrix, thats extra-stuff that needs be done every time i submit matrixes to the pipeline.

Is there an alternative way?
[1] https://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml

element-wise clamp

Wouldn't it be neat to be able to write:

assert(clamp(vec2(-4.3, 2), -3, 4) == vec2(-3, 2));
assert(clamp(vec2(-2, 4), vec2(0, 0), vec2(1, 3)) == vec2(0, 3));

[RFE] Add a camera module

A replacement for calls such as glFrustum and glOrtho would be nice. I can work on it if you're open to it.

Compiling example code

I don't know what to put for the import thing.

import gl3n.aabb : vec3;

void main() {
vec4 v4 = vec4(1.0f, vec3(2.0f, 3.0f, 4.0f));
vec4 v4_2 = vec4(1.0f, vec4(1.0f, 2.0f, 3.0f, 4.0f).xyz); // "dynamic" swizzling with opDispatch
vec4 v4_3 = v4_2.xxyz; // opDispatch returns a static array which you can pass directly to the ctor of a vector!

vec3 v3 = my_3dvec.rgb;
vec3 foo = v4.xyzzzwzyyxw.xyz; // not useful but possible!

mat4 m4fv = mat4.translation(-0.5f, -0.54f, 0.42f).rotatex(PI).rotatez(PI/2);
glUniformMatrix4fv(location, 1, GL_TRUE, m4fv.value_ptr); // yes they are row major!

alias Matrix!(double, 4, 4) mat4d;
mat4d projection;
glGetDoublev(GL_PROJECTION_MATRIX, projection.value_ptr);

mat3 inv_view = view.rotation;
mat3 inv_view = mat3(view);

mat4 m4 = mat4(vec4(1.0f, 2.0f, 3.0f, 4.0f), 5.0f, 6.0f, 7.0f, 8.0f, vec4(1,2,3,4), vec4(1,2,3,4)); 

}

Cannot properly use shared with vecN.

shared vec2 pos;

vec2 getPosition() {
return cast(vec2)pos; //does not work
return vec2(pos.x, pos.y); //does not work
return vec2(pos.vector[0], pos.vector[1]); //does work
}

am I doing something wrong?

travis-ci integration

copy paste from issue #49:

i cannot reproduce the issue on win32 using dmd2.065. @Dav1dde maybe a travis-ci integration can prevent those issues in the future? it is easy to integrate to even test multiple compiler flavours and its free ;)

Non-square matrix multiplication and 1xM and Nx1 matrices

Hi

I would like to do some general linear algebra using the Matrix type but I ran into a couple of issues.

Matrix!(float, 2, 5) A;
A[0][0] = 0;    A[0][1] = 1;    A[0][2] = 2;    A[0][3] = 3;    A[0][4] = 4;
A[1][0] = 5;    A[1][1] = 6;    A[1][2] = 7;    A[1][3] = 8;    A[1][4] = 9;
writeln(A.as_pretty_string);        
Matrix!(float, 5, 2) B;
B[0][0] = 0;    B[0][1] = 1;
B[1][0] = 2;    B[1][1] = 3;
B[2][0] = 4;    B[2][1] = 5;
B[3][0] = 6;    B[3][1] = 7;
B[4][0] = 8;    B[4][1] = 9;
writeln(B.as_pretty_string);
// Compiles but produces the wrong result (half of the matrix is filled with nan's)
auto res1 = B * A;      
writeln(res1.as_pretty_string);
// Gives loads of out of bounds errors on compile time.
auto res2 = A * B;
// Gives a couple of out of bounds errors on compile time.
Matrix!(float, 1, 5) C;
// Ditto
Matrix!(float, 5, 1) D;

Matrix decomposition

There is no way to do decomposition on gl3n , right?
Like on glm:
glm::decompose(transformation, scale, rotation, translation, skew, perspective);

Quaternion.from_matrix

Produced weird results, so I redid it using http://www.flipcode.com/documents/matrfaq.html#Q55 as a reference and now it seems to work. fingers crossed

    /// Creates a quaternion from a 3x3 matrix.
    /// Params:
    ///  matrix = 3x3 matrix (rotation)
    /// Returns: A quaternion representing the rotation (3x3 matrix)
    static Quaternion from_matrix(Matrix!(qt, 3, 3) matrix) {
        Quaternion ret;

        auto mat = matrix.matrix;
        qt trace = mat[0][0] + mat[1][1] + mat[2][2] + 1.0;

        if(trace > 0) {
            real s = 0.5 / sqrt(trace);

            ret.w = to!qt(0.25 / s);
            ret.x = to!qt((mat[2][1] - mat[1][2]) * s);
            ret.y = to!qt((mat[0][2] - mat[2][0]) * s);
            ret.z = to!qt((mat[1][0] - mat[0][1]) * s);
        } else if((mat[0][0] > mat[1][1]) && (mat[0][0] > mat[2][2])) {
            real s = 2.0 * sqrt(1 + mat[0][0] - mat[1][1] - mat[2][2]);

            ret.w = to!qt((mat[2][1] + mat[1][2]) / s);
            ret.x = to!qt(0.5 / s);
            ret.y = to!qt((mat[0][1] + mat[1][0]) / s);
            ret.z = to!qt((mat[0][2] + mat[2][0]) / s);
        } else if(mat[1][1] > mat[2][2]) {
            real s = 2.0 * sqrt(1 + mat[1][1] - mat[0][0] - mat[2][2]);

            ret.w = to!qt((mat[0][2] + mat[2][0]) / s);
            ret.x = to!qt((mat[0][1] + mat[1][0]) / s);
            ret.y = to!qt(0.5 / s);
            ret.z = to!qt((mat[1][2] + mat[2][1]) / s);
        } else {
            real s = 2.0 * sqrt(1 + mat[2][2] - mat[0][0] - mat[1][1]);

            ret.w = to!qt((mat[1][0] + mat[0][1]) / s);
            ret.x = to!qt((mat[0][2] + mat[2][0]) / s);
            ret.y = to!qt((mat[1][2] + mat[2][1]) / s);
            ret.z = to!qt(0.5f / s);
        }

        return ret;
    }

I hope the code compiles as I did it in a text editor using the separate function I got working in my project =)

v1.0.1 ?

When dmd 2.067 comes out, gl3n v1.0.0 won't compile with it due to not having (some of) the changes from #43

A v1.0.1 patch release would be nice.

slerp issues

I have absolutely no idea why this is happening, but apprantly there are certain magical quaternions that cannot be interpolated between.

    quat a = quat.yrotation(-1.238796f);
    quat b = quat.yrotation(-1.238796f);    
    quat bad = slerp(a, b, 0.5);    
    quat a2 = quat.yrotation(-1.23879f);
    quat b2 = quat.yrotation(-1.23879f);    
    quat good = slerp(a2, b2, 0.5); 
    writeln(a, " ", b, " ", bad, " ", good, ".");

Having done a bit of research on slerp it turns out that its "bad practice" anyway:
http://physicsforgames.blogspot.com/2010/02/quaternions.html
http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/

If it is not too much trouble, I'd like to see nlerp along with a fixed version of slerp in the interpolate module.
My version looks like this:

quat nlerp(quat a, quat b, float t) {
    float dot = a.w * b.w + a.x * b.x + a.y * b.y + a.z * b.z;      
    quat result;
    if(dot < 0) {   // Determine the "shortest route"...
        result = a - (b + a) * t;   // use -b instead of b
    } else {
        result = a + (b - a) * t;
    }
    result.normalize();
    return result;
}

, but I guarrantee nothing as the bug above is completely blowing my mind.

N-dimension AABB

I'm doing 2d calculations, and having a 2d AABB would be nice.

I'm currently working on a PR for n-dimension AABB which dimensions are defined at compile time (inspired from how Vector works)

Matrix Type is unable to handle non floating-point types and real

This will produce tons of errors (at least with dmd 2.059):

alias Matrix!(int, 2, 2) mat2i;
alias Matrix!(int, 3, 3) mat3i;
alias Matrix!(int, 4, 4) mat4i;

alias Matrix!(long, 2, 2) mat2l;
alias Matrix!(long, 3, 3) mat3l;
alias Matrix!(long, 4, 4) mat4l;

Interestingly the real type also fails to compile

Matrix invert optimization

This needs to be tested, but I believe it should work:

private Matrix invert(ref Matrix mat) const {
    mt d =  1.0 / det;

    mat.matrix = [[
        ( ... ) * d,
        // etc...
    ]];

    return mat;
}

euler_rotation and pitch/yaw/roll broken

it took me hours to finally realize those methods are broken instead of my code using them ^^

consider the following test case:

unittest{
    enum startPitch = 0.1;
    enum startYaw = -0.2;
    enum startRoll = 0.6;

    import std.stdio;
    writefln("%s,%s,%s",startPitch,startYaw,startRoll);

    auto q = quat.euler_rotation(startRoll,startPitch,startYaw);

    writefln("%s,%s,%s",q.pitch,q.yaw,q.roll);

    assert(almost_equal(q.pitch,startPitch),.format("%s != %s",q.pitch,startPitch));
    assert(almost_equal(q.yaw,startYaw),.format("%s != %s",q.yaw,startYaw));
    assert(almost_equal(q.roll,startRoll),.format("%s != %s",q.roll,startRoll));
}

essentially we take euler angles, create a quaternion of them and get the euler angles from that quaternion again. this should work without loosing any information. the above test case tries that. it fails.

then i examined the wiki page for euler angles and found that all four methods are defined different than in your implementation: http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles

my implementation looks like this and solves the issue but breaks some of your unittests where u hardcoded what seems to be wrong results:

/// Returns the yaw.
    @property real yaw() const {
        return atan2(2.0*(w*z + x*y), 1.0 - 2.0*(y*y + z*z));
    }

    /// Returns the pitch.
    @property real pitch() const {
        return asin(2.0*(w*y - z*x));
    }

    /// Returns the roll.
    @property real roll() const {
        return atan2(2.0*(w*x + y*z), 1.0 - 2.0*(x*x + y*y));
    }

static Quaternion euler_rotation(real roll, real pitch, real yaw) {
        Quaternion ret;

        auto cr = cos(roll / 2.0);
        auto cp = cos(pitch / 2.0);
        auto cy = cos(yaw / 2.0);
        auto sr = sin(roll / 2.0);
        auto sp = sin(pitch / 2.0);
        auto sy = sin(yaw / 2.0);

        ret.w = cr * cp * cy + sr * sp * sy;
        ret.x = sr * cp * cy - cr * sp * sy;
        ret.y = cr * sp * cy + sr * cp * sy;
        ret.z = cr * cp * sy - sr * sp * cy;

        return ret;
    }

Mark most things as explicitly @nogc

As the library looks like it should be possible to mark everything as @nogc, perhaps it would be a good idea to actually do so? This would give the extra assurance that the library is perfect for use in an environment where the GC is the enemy.

Cannot create a vector of ubytes

Hey, I cannot create a vector of ubytes because of this error:

Building configuration "application", build type debug
Compiling...
../../../../../.dub/packages/gl3n-master/gl3n/linalg.d(147): Error: static assert  "Vector constructor argument must be of type ubyte or Vector, not int"
../../../../../.dub/packages/gl3n-master/gl3n/linalg.d(167):        instantiated from here: construct!(0, int, int, int)
../../../../../.dub/packages/gl3n-master/gl3n/linalg.d(93):        instantiated from here: __ctor!(int, int, int)
source/loadpnm.d(12):        instantiated from here: Vector!(ubyte, 3)
Error: DMD compile run failed with exit code 1

Run 'dub help' for usage information.

AABBT!int doesn't work

It isn't possible to instantiate the AABBT-template with an int, it gives an error on this line since the constructor of the vec3s are hardcoded to be of type float.

Proposed solution: instantiate with cast(type)0.0 instead

Problem observed with DMD32 D Compiler v2.074.0 on windows

Vector!(ushort,3) constructor

I have a problem getting the following code to run. I'm not sure whether the problem lies with the compiler, the library or with me.

I want to do the following:

alias Vector!(ushort,3) TriIndices;
auto Test = TriIndices(1,2,3);

But I get the following error from the compiler:
"gl3n/linalg.d(125): Error: static assert "Vector constructor argument must be of type ushort or Vector, not int"

Thanks for your help.

When vecN is used with tuples, 'dub test' fails.

I having run dub test, many linker errors happen.

Source

/dub.json

{
  "name": "temp",
  "dependencies": {
    "gl3n": "~>1.3.1"
  }
}

/src/main.d

import std;
import gl3n.linalg;

void main() {
  Tuple!vec2 tuple;
}

Output

$ dub test
No source files found in configuration 'library'. Falling back to "dub -b unittest".
Performing "unittest" build using /usr/bin/dmd for x86_64.
gl3n 1.3.1: target for configuration "library" is up to date.
temp ~master: building configuration "application"...
Linking...
/usr/bin/ld: .dub/build/application-unittest-linux.posix-x86_64-dmd_2087-6042B5CA26865B98B64101D410178581/temp.o: in function `_D4gl3n6linalg__T6VectorTfVii2ZQo20__unittest_L388_C5_1FNaNbNfZv':
/home/username/temp/../.dub/packages/gl3n-1.3.1/gl3n/gl3n/linalg.d:392: undefined reference to `_D4gl3n6linalg__T6VectorTfVii3ZQo__T10opDispatchVAyaa6_7879627a7972ZQBgMxFNaNbNdNiNfZSQDgQDe__TQDaTfVii6ZQDk'
/usr/bin/ld: /home/username/temp/../.dub/packages/gl3n-1.3.1/gl3n/gl3n/linalg.d:396: undefined reference to `_D4gl3n6linalg__T6VectorTfVii4ZQo__T10opDispatchVAyaa6_7767797a6178ZQBgMxFNaNbNdNiNfZSQDgQDe__TQDaTfVii6ZQDk'
/usr/bin/ld: .dub/build/application-unittest-linux.posix-x86_64-dmd_2087-6042B5CA26865B98B64101D410178581/temp.o: in function `_D4gl3n6linalg__T6VectorTfVii6ZQo20__unittest_L388_C5_2FNaNbNfZv':
/home/username/temp/../.dub/packages/gl3n-1.3.1/gl3n/gl3n/linalg.d:392: undefined reference to `_D4gl3n6linalg__T6VectorTfVii3ZQo__T10opDispatchVAyaa6_7879627a7972ZQBgMxFNaNbNdNiNfZSQDgQDe__TQDaTfVii6ZQDk'
/usr/bin/ld: /home/username/temp/../.dub/packages/gl3n-1.3.1/gl3n/gl3n/linalg.d:396: undefined reference to `_D4gl3n6linalg__T6VectorTfVii4ZQo__T10opDispatchVAyaa6_7767797a6178ZQBgMxFNaNbNdNiNfZSQDgQDe__TQDaTfVii6ZQDk'
/usr/bin/ld: .dub/build/application-unittest-linux.posix-x86_64-dmd_2087-6042B5CA26865B98B64101D410178581/temp.o: in function `_D4gl3n6linalg__T6VectorTfVii3ZQo20__unittest_L388_C5_3FNaNbNfZv':
/home/username/temp/../.dub/packages/gl3n-1.3.1/gl3n/gl3n/linalg.d:392: undefined reference to `_D4gl3n6linalg__T6VectorTfVii3ZQo__T10opDispatchVAyaa6_7879627a7972ZQBgMxFNaNbNdNiNfZSQDgQDe__TQDaTfVii6ZQDk'
/usr/bin/ld: /home/username/temp/../.dub/packages/gl3n-1.3.1/gl3n/gl3n/linalg.d:396: undefined reference to `_D4gl3n6linalg__T6VectorTfVii4ZQo__T10opDispatchVAyaa6_7767797a6178ZQBgMxFNaNbNdNiNfZSQDgQDe__TQDaTfVii6ZQDk'
/usr/bin/ld: .dub/build/application-unittest-linux.posix-x86_64-dmd_2087-6042B5CA26865B98B64101D410178581/temp.o: in function `_D4gl3n6linalg__T6VectorTfVii4ZQo20__unittest_L388_C5_4FNaNbNfZv':
/home/username/temp/../.dub/packages/gl3n-1.3.1/gl3n/gl3n/linalg.d:392: undefined reference to `_D4gl3n6linalg__T6VectorTfVii3ZQo__T10opDispatchVAyaa6_7879627a7972ZQBgMxFNaNbNdNiNfZSQDgQDe__TQDaTfVii6ZQDk'
/usr/bin/ld: /home/username/temp/../.dub/packages/gl3n-1.3.1/gl3n/gl3n/linalg.d:396: undefined reference to `_D4gl3n6linalg__T6VectorTfVii4ZQo__T10opDispatchVAyaa6_7767797a6178ZQBgMxFNaNbNdNiNfZSQDgQDe__TQDaTfVii6ZQDk'
/usr/bin/ld: .dub/build/application-unittest-linux.posix-x86_64-dmd_2087-6042B5CA26865B98B64101D410178581/temp.o: in function `_D4gl3n6linalg__T6VectorTfVii5ZQo20__unittest_L388_C5_7FNaNbNfZv':
/home/username/temp/../.dub/packages/gl3n-1.3.1/gl3n/gl3n/linalg.d:392: undefined reference to `_D4gl3n6linalg__T6VectorTfVii3ZQo__T10opDispatchVAyaa6_7879627a7972ZQBgMxFNaNbNdNiNfZSQDgQDe__TQDaTfVii6ZQDk'
/usr/bin/ld: /home/username/temp/../.dub/packages/gl3n-1.3.1/gl3n/gl3n/linalg.d:396: undefined reference to `_D4gl3n6linalg__T6VectorTfVii4ZQo__T10opDispatchVAyaa6_7767797a6178ZQBgMxFNaNbNdNiNfZSQDgQDe__TQDaTfVii6ZQDk'
/usr/bin/ld: .dub/build/application-unittest-linux.posix-x86_64-dmd_2087-6042B5CA26865B98B64101D410178581/temp.o: in function `_D4gl3n6linalg__T6VectorTfVii12ZQp20__unittest_L388_C5_8FNaNbNfZv':
/home/username/temp/../.dub/packages/gl3n-1.3.1/gl3n/gl3n/linalg.d:392: undefined reference to `_D4gl3n6linalg__T6VectorTfVii3ZQo__T10opDispatchVAyaa6_7879627a7972ZQBgMxFNaNbNdNiNfZSQDgQDe__TQDaTfVii6ZQDk'
/usr/bin/ld: /home/username/temp/../.dub/packages/gl3n-1.3.1/gl3n/gl3n/linalg.d:396: undefined reference to `_D4gl3n6linalg__T6VectorTfVii4ZQo__T10opDispatchVAyaa6_7767797a6178ZQBgMxFNaNbNdNiNfZSQDgQDe__TQDaTfVii6ZQDk'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
/usr/bin/dmd failed with exit code 1.
$ dub --version
DUB version 1.16.0, built on Jul 02 2019
$ dmd --version
DMD64 D Compiler v2.087.0

Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved written by Walter Bright
$ uname -r
5.2.1-arch1-1-ARCH

TypeTuple not found

gl3n 1.2.0: building configuration "library"...
../../../../../.dub/packages/gl3n-1.2.0/gl3n/util.d(14,12): Error: module std.typecons import 'TypeTuple' not found, did you mean template 'isTypeTuple(T...)'?

Project Status

It looks like this repo has not been modified since January. Is that because the code is stable and works well, or because the project is dead, or maybe just that no one is using it? I'm doing some OpenGL work in D and wanted to use an existing library for GLM instead of writing my own. In your opinion, is this the right project to go with, or another project?

Matrix Translate resulting in different values from glm

So basically, I'm trying to replicate what I've written in C++ into Dlang.

I have this as the Dlang code.

vec2 pos;
vec2 size;
float rotate;

pos.x = pos.y = 0;
size.x = size.y = 500;
rotate = 0;

mat4 model = mat4.identity;
writeln("Initial :");
writeln(model);
SDL_Delay(2000);

model = model.translate(vec3(pos,0.0f));
writeln("First :");
writeln(model);
SDL_Delay(2000);

model = model.rotation(rotate,vec3(pos,1.0f));
writeln("Second :");
writeln(model);
SDL_Delay(2000);

model = model.translate(vec3(-0.5f * size.x, -0.5f * size.y, 0.0f));
writeln("Third :");
writeln(model);
SDL_Delay(2000);

model = model.scale(size.x,size.y,1.0f);
writeln("Fourth :");
writeln(model);
SDL_Delay(2000);

And this as the C++ code:

    glm::vec2 pos;
    glm::vec2 size;
    GLfloat rotate;

    pos.x = pos.y = 0;
    size.x = size.y = 500;
    rotate = 0;

    glm::mat4 model;
    std::cout << "Initial : \n" << glm::to_string(model) << std::endl;
    SDL_Delay(2000);

    model = glm::translate(model,glm::vec3(pos, 0.0f));
    std::cout << "First : \n" << glm::to_string(model) << std::endl;
    SDL_Delay(2000);

    model = glm::rotate(model,rotate,glm::vec3(pos,1.0f));
    std::cout << "Second : \n" << glm::to_string(model) << std::endl;
    SDL_Delay(2000);

    model = glm::translate(model,glm::vec3(-0.5f * size.x, -0.5f * size.y, 0.0f));
    std::cout << "Third :\n" << glm::to_string(model) << std::endl;
    SDL_Delay(2000);

    model = glm::scale(model,glm::vec3(size,1.0f));
    std::cout << "Fourth :\n" << glm::to_string(model) << std::endl;
    SDL_Delay(2000);

And the results are different:

Dlang code:

image

C++ code:

image

At first, the values are basically the same, then it starts to differ at the third output.

Dlang code:
model = model.translate(vec3(-0.5f * size.x, -0.5f * size.y, 0.0f))

C++ code:
model = glm::translate(model,glm::vec3(-0.5f * size.x, -0.5f * size.y, 0.0f))

I'm not sure if this is a bug or not, I just don't know where to post it.
I am probably doing something wrong here, but I'm still trying to wrap my head around matrices in general.
If this is not a bug, then I'm very sorry for wasting your time.

Documentation

The documentation at http://dav1dde.github.io/gl3n/index.html is incomplete/outdated. I was using it as a reference and didn't find the perspective/look_at methods and attempted doing them myself. After failing for a good amount of time i read your BraLa code and found they actually do exist! Updating the online documentation would be very helpful or at least a warning that it is not up to date to save other people my issue.

Thanks!

Gitignore

Please add these lines to a .gitignore, so one can directly use your repo as a submodule and build inside, without having the "files changed" info all the time...

build/
doc/
gl3n.pc
import/
lib/

hsv2rgb vs. rgb2hsv

Hope I'm not spamming, but I wanted to get this down before I knocked off for the night in case I forgot.

I haven't looked carefully yet, but I think rgb2hsv returns hue in 360 degrees, while hsv2rgb expects hue in 0-1 range.

A comment in the source code would be very helpful!

dmd 2.065 compilation issue

After compilation math.di interface is generated with errors. Return type for "clamp" and "smoothstep" functions is missing (must be "auto"). It can be not related to specific compiler version, but it used to work properly with previous compiler version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.