错误:二进制'operator*' 'float'和'float[0]'类型的操作数无效
Error: invalid operands of types 'float' and 'float[0]' to binary 'operator*'
所以我有这个图形管道的代码,但由于某种原因我遇到了错误。
#include <GL/glut.h>
#include <stdio.h>
#include <unistd.h>
#define UpperBD 3
#define Xe 200
#define Ye 200
#define Ze 200
#define Rho sqrt(sq(Xe) + sq(Ye) + sq(Ze))
#define PI 3.1415926
#define D_focal 20
typedef struct {
float X[] = {};
float Y[] = {};
float Z[] = {};
} pworld;
typedef struct {
float X[] = {};
float Y[] = {};
float Z[] = {};
} pviewer;
typedef struct{
float X[] = {};
float Y[] = {};
} pperspective;
void mydisplay()
{
float p1x = 0.0f, p1y = 1.0f; //the window coordinates (-1.0, 1.0)
float p2x = 0.0f, p2y = -1.0f;
float p3x = 1.0f, p3y = 0.0f;
float p4x = -1.0f, p4y = 0.0f;
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
/* Line starts */
glBegin(GL_LINES);
glVertex2f(p1x, p1y);
glVertex2f(p2x, p2y);
glVertex2f(p3x, p3y);
glVertex2f(p4x, p4y);
glEnd();
/* Line Ends */
// #define Pheta = PI/4.0;
// #define Phi =
/* World to viewer */
pworld world[3];
pviewer viewer[3];
pperspective perspective[3];
float sPheta = Ye / sqrt(sq(Xe) + sq(Ye));
float cPheta = Xe / sqrt(sq(Xe) + sq(Ye));
float sPhi = sqrt(sq(Xe) + sq(Ye)) / Rho;
float cPhi = Ze / Rho;
for(int i = 0; i <= UpperBD; i++)
{
viewer[i].X = -sPheta * world[i].X; + cPheta * world[i].y;
viewer[i].Y = -cPheta * cPhi * world[i].X
- cPhi * sPheta * world[i].Y
+ sPhi * world[i].Z;
viewer[i].Z = -sPhi * cPheta * world[i].X
- sPhi * cPheta * world[i].Y
-cPheta * world[i].Z + Rho;
perspective[i].X = (D_focal / viewer[i].Z) * viewer[i].X;
perspective[i].Y = (D_focal / viewer[i].Z) * viewer[i].Y;
cout << perspective[i].X << endl;
cout << perspective[i].Y << endl;
}
glFlush();
usleep(50);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutCreateWindow("William");
glutDisplayFunc(mydisplay);
glutMainLoop();
}
错误发生在viewer[i].X = -sPheta * world[i].X; + cPheta * world[i].y;
处,以及for
循环中它下面的行。我不确定发生了什么。 我正在尝试将float
乘以float[]
,但它不起作用。
typedef struct {
float X[] = {};
float Y[] = {};
float Z[] = {};
} pworld;
它的结构由 3 个零元素(空(C 数组组成。-sPheta * world[i].X;
将浮点数(数字(与空数组相乘 - 您想实现什么?我想你不需要这些[]。
但是,我认为禁止零元素 C 数组,但它编译得很好。
相关文章:
- 数组下标的类型"float*[float]"无效
- 错误:二进制'operator*' 'float'和'float[0]'类型的操作数无效
- 编译器给出错误:format 指定类型 'float *',但参数的类型'double' [-Wformat]
- OPENCL 警告:不兼容的指针类型将'float __global[16]'传递给类型为 '__global float4 的参数 *
- "错误:数组下标的无效类型'float [10001][float]'是什么意思?
- 将"float*"赋值为"float* [1000]"中的不兼容类型
- 数组类型 'float [size]'不可分配
- 错误:二进制'operator*' 'int [1]'和'float'类型的操作数无效
- 功能使用INT和Float类型作为C 中的参数过载
- Qt C++ - 不允许使用 QList<float**> 类型
- 为什么主函数不识别其他功能是否返回float类型编号
- QList<float* 类型的 NULL 返回值>
- 为什么我的方法不从文件.txt中读取float类型
- 自定义构件上的 float 类型的Q_PROPERTY不会显示在属性编辑器中
- 为什么用“std::chrono”进行时差测量时,与“double”类型相比,用“float”类型给出的有效数字更多
- 在当前的C++和Java中,double类型和float类型:if(x==0.0)是正确的
- 将double/float类型转换为string类型,保留科学记数法和精度
- c++中两个float类型变量的精确比较
- 为什么要将float类型的指针转换为long类型的指针,然后解引用呢?
- 如何在OpenCV中限制float类型Mat精度