1
基本上我有一辆汽车(矩形)在2D空间中移动。 追踪与其他物体进行基本碰撞检测的角点。 我无法正确地计算出三角函数。 目前,我有以下几点:跟踪正在移动的旋转矩形的角C++ openGL
this->FL.x = this->position.x - this->C_width/2*cos(this->spinY*pi/180) + this->C_length/2*sin(this->spinY*pi/180);
this->FL.y = this->position.z + this->C_length/2*sin(this->spinY*pi/180) - this->C_width/2*cos(this->spinY*pi/180);
this->FR.x = this->position.x + this->C_width/2*cos(this->spinY*pi/180) + this->C_length/2*sin(this->spinY*pi/180);
this->FR.y = this->position.z + this->C_length/2*sin(this->spinY*pi/180) + this->C_width/2*cos(this->spinY*pi/180);
this->BL.x = this->position.x - this->C_width/2*cos(this->spinY*pi/180) - this->C_length/2*sin(this->spinY*pi/180);
this->BL.y = this->position.z - this->C_length/2*sin(this->spinY*pi/180) - this->C_width/2*cos(this->spinY*pi/180);
this->BR.x = this->position.x + this->C_width/2*cos(this->spinY*pi/180) - this->C_length/2*sin(this->spinY*pi/180);
this->BR.y = this->position.z - this->C_length/2*sin(this->spinY*pi/180) + this->C_width/2*cos(this->spinY*pi/180);
你正在使用opengl,因为我看到了,那么如果你用矩阵旋转/移动它,你也可以在cpu上得到它们的坐标。 –
我知道它很重要,但是真的需要所有这些'this->'前缀吗?你的代码是非常不可读的。 – Shoe