Is there any class for Matrix support in Objective-C? By Matrix I mean 2D-arrays.
What I do now is using 2 NSArray
s, one within the other. This works perfectly but my code looks like a big mess.
I have also tried to use C-style arrays within each-other (matrix[][]
) but this approach doesn't fit my application as I cannot automatically @synthesize
or specify @properties
for them.
I could of course create my own class for that, but what I'm wondering is if Objective-C already has something for this kind of situations. I did some Google-research but didn't find anything.
Nope, Foundation doesn't have any 2D array class. As far as mathematical computations are concerned, Matrices are typically implemented in C or C++ for portability and performance reasons. You'll have to write your own class for that if you really want it.
It seems obj-c has not its own struct for matrix. I refered to the iOS SDK's CATransform3D, found that it use:
struct CATransform3D
{
CGFloat m11, m12, m13, m14;
CGFloat m21, m22, m23, m24;
CGFloat m31, m32, m33, m34;
CGFloat m41, m42, m43, m44;
};
typedef struct CATransform3D CATransform3D;
as the 3D transform matrix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With