Objective-C中向量_float2*的C数组
如何生成“vector_float2*”的C数组?你能给我举个例子吗?你需要知道的一切:Objective-C中向量_float2*的C数组,objective-c,Objective C,如何生成“vector_float2*”的C数组?你能给我举个例子吗?你需要知道的一切: // simple C array: type identifier[] = {value,value,...}; // example: int myIntegers[] = {1,2,3}; // Note that specifying the size is optional. // example of a vector_float2 value: vector_float2 m
// simple C array: type identifier[] = {value,value,...};
// example: int myIntegers[] = {1,2,3};
// Note that specifying the size is optional.
// example of a vector_float2 value: vector_float2 myVector = {1.0,1.0};
// array of 9 (3x3) vector_float2 values:
vector_float2 myVectors[] = {
{0.0,0.0},{0.5,0.0},{1.0,0.0},
{0.0,0.5},{0.5,0.5},{1.0,0.5},
{0.0,1.0},{0.5,1.0},{1.0,1.0}
};
// Note that vector_float2 * and vector_float2 [] are interchangeable:
vector_float2 * vectors = myVectors
vector_float2 aVector = vectors[4];
printf("vector x:%f y:%f\n",aVector.x,aVector.y);
您需要知道的是:
// simple C array: type identifier[] = {value,value,...};
// example: int myIntegers[] = {1,2,3};
// Note that specifying the size is optional.
// example of a vector_float2 value: vector_float2 myVector = {1.0,1.0};
// array of 9 (3x3) vector_float2 values:
vector_float2 myVectors[] = {
{0.0,0.0},{0.5,0.0},{1.0,0.0},
{0.0,0.5},{0.5,0.5},{1.0,0.5},
{0.0,1.0},{0.5,1.0},{1.0,1.0}
};
// Note that vector_float2 * and vector_float2 [] are interchangeable:
vector_float2 * vectors = myVectors
vector_float2 aVector = vectors[4];
printf("vector x:%f y:%f\n",aVector.x,aVector.y);
Objective-C是C的超集。如果你能在C中创建数组,你知道如何在Objective-C中创建,因为它是相同的。Objective-C是C的超集。如果你能在C中创建数组,你知道如何在Objective-C中创建,因为它是相同的。