samb90
samb90

Reputation: 1073

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

Upvotes: 0

Views: 238

Answers (2)

Tommy
Tommy

Reputation: 100632

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);

Upvotes: 2

indragie
indragie

Reputation: 18122

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.

Upvotes: 1

Related Questions