简体   繁体   中英

iOS Matrix and Vector Operations

I am in the process of converting a Web GL application into iOS.

The web gl version of the app uses the gl-matrix package ( https://github.com/toji/gl-matrix ) to perform matrix and vector operations.

I was wondering what the equivalent package would be in iOS?

For instance one of the lines of code in the javascript application uses the line:

return new glMatrixArrayType([x * sin2, y * sin2, z * sin2, Math.cos(a2)]);

In iOS what should I use instead of glMatrixArrayType.

Cheers, Sam

Assuming you mean iOS 5+, the equivalent is GLKit . Prior to that you were on your own as far as the OS was concerned.

It doesn't have a 2x2 matrix so the equivalent to that line of code would be (well, probably, unless I've got my rows and columns transposed — I don't know gl-matrix):

return GLKMatrix3Make(
          x * sin2, y * sin2, 0.0f,
          z*sin2,   cos(a2),  0.0f, 
          0.0f,     0.0f,     1.0f);

iOS's matrix and vector library is called vecLib . Documentation can be found here . I'm unfamiliar with it, however, so I wouldn't know the exact equivalent of glMatrixArrayType in vecLib, but hopefully this points you in the right direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM