改变 3d 轨道物体相对于 x 轴的角度
所以当你向下看 z 轴时,我试图改变物体相对于 x 轴的轨道角度。看图片了解我的意思:
我目前正在使用此代码绕两个红色球体运行:
public void orbit() {
theta += this.vel.x;
theta = fixAngle(theta, TWO_PI);
this.loc.x = this.origin.x+orbitRadius*cos(theta);
this.loc.y = this.origin.y+orbitRadius*cos(theta);
this.loc.z = this.origin.z+orbitRadius*sin(theta);
}
private float fixAngle(float ang, float range) {
if (ang < 0)
ang += range;
else if (ang > range)
ang -= range;
return ang;
}
有人知道如何做吗我能做到这一点吗?
so i am trying to change the angle at which the object orbits in relation to the x-axis as you are looking down the z-axis. see the picture for what i mean:
i am currently using this code to orbit the two red spheres:
public void orbit() {
theta += this.vel.x;
theta = fixAngle(theta, TWO_PI);
this.loc.x = this.origin.x+orbitRadius*cos(theta);
this.loc.y = this.origin.y+orbitRadius*cos(theta);
this.loc.z = this.origin.z+orbitRadius*sin(theta);
}
private float fixAngle(float ang, float range) {
if (ang < 0)
ang += range;
else if (ang > range)
ang -= range;
return ang;
}
does anyone know how i can accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,可以通过不旋转轨道物体而是通过旋转坐标系来完成,如所回答的 此处
apparently it can be done by not rotating the orbiting object but by rotating the coordinate system as answered HERE