Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从GLKVector3提取X和Y?网间网操作系统_Ios_Objective C_Opengl Es_Glkit - Fatal编程技术网

Ios 从GLKVector3提取X和Y?网间网操作系统

Ios 从GLKVector3提取X和Y?网间网操作系统,ios,objective-c,opengl-es,glkit,Ios,Objective C,Opengl Es,Glkit,假设我有一个GLKVector3,并且只想将x和y值读取为CGPoints-我如何才能做到这一点?在中,有类型定义: union _GLKVector3 { struct { float x, y, z; }; struct { float r, g, b; }; struct { float s, t, p; }; float v[3]; }; typedef union _GLKVector3 GLKVector3; 有三种选择: GLKVector3的v属性

假设我有一个GLKVector3,并且只想将x和y值读取为CGPoints-我如何才能做到这一点?

在中,有类型定义:

union _GLKVector3
{
   struct { float x, y, z; };
   struct { float r, g, b; };
   struct { float s, t, p; };
      float v[3];
};
typedef union _GLKVector3 GLKVector3;
有三种选择:

GLKVector3
v
属性,它是
float[3]
数组
{x,y,z}

i、 e:

对于向量类型的不同用途,还有浮点属性
x、y、z
或更不相关的
r、g、b
s、t、p

CGPoint p = CGPointMake(vector.x,vector.y);
在中,有类型定义:

union _GLKVector3
{
   struct { float x, y, z; };
   struct { float r, g, b; };
   struct { float s, t, p; };
      float v[3];
};
typedef union _GLKVector3 GLKVector3;
有三种选择:

GLKVector3
v
属性,它是
float[3]
数组
{x,y,z}

i、 e:

对于向量类型的不同用途,还有浮点属性
x、y、z
或更不相关的
r、g、b
s、t、p

CGPoint p = CGPointMake(vector.x,vector.y);

GLKVector3
声明为

union _GLKVector3
{
    struct { float x, y, z; };
    struct { float r, g, b; };
    struct { float s, t, p; };
    float v[3];
};
typedef union _GLKVector3 GLKVector3;
因此,最简单、可读性最强的转换方法是:

GLKVector3 someVector;
…
CGPoint somePoint = CGPointMake(someVector.x,someVector.y);

但是请注意,
CGPoint
CGFloat
组成,在64位环境中可能是双精度。

GLKVector3
声明为

union _GLKVector3
{
    struct { float x, y, z; };
    struct { float r, g, b; };
    struct { float s, t, p; };
    float v[3];
};
typedef union _GLKVector3 GLKVector3;
因此,最简单、可读性最强的转换方法是:

GLKVector3 someVector;
…
CGPoint somePoint = CGPointMake(someVector.x,someVector.y);
但是请注意,
CGPoint
CGFloat
组成,在64位环境中可能是双精度。

关于64位的好观点——如果需要转换这两种方式和/或写出可能在不同设备架构上读取的数据,您需要小心。关于64位的好观点——如果您需要需要转换两种方式和/或写出可能在不同设备架构上读取的数据。