简体   繁体   English

将3D点位置转换为2D点位置

[英]Translate 3D point location to 2D point location

Below is the screenshot of the 3d object. 以下是3d对象的屏幕截图。 This is a 3D Radar Chart where the depth is a time. 这是3D雷达图,其中深度是时间。 As you see labels are spinning in 3d also, is there a way to determine just X and Y positions by looking up at X, Y, and Z so that I can just display those labels as flat 2D labels that are not spinning but moving along with the 3D object. 如您所见,标签也在3d中旋转,有一种方法可以通过抬头查看X,Y和Z来确定X和Y的位置,这样我就可以将这些标签显示为不旋转但沿其移动的平面2D标签3D对象。

To produce that diagram I'm using Processing and Processing.js which is plain Java and because I'm using JS I have limitation to add any additional libraries. 为了生成该图,我使用的是Processing和Processing.js,这是纯Java,并且由于我使用的是JS,因此我必须限制添加任何其他库。

在此处输入图片说明

To achieve what you want you need to obtain the model-view-projection matrix from your PGraphics object (ie projmodelview field in PGraphicsOpenGL ) and, assuming you have your XYZ coordinates as a PVector , multiply it with your matrix to obtain a vector whose X and Y coordinates are on the screen. 为了达到你想要什么,你需要从获得的模型-视图-投影矩阵PGraphics对象(即projmodelview现场PGraphicsOpenGL ),并假设你有你的XYZ坐标为PVector ,与矩阵相乘获得一个向量,其X和Y坐标在屏幕上。

You can then use those coordinates to draw your labels on your canvas. 然后,您可以使用这些坐标在画布上绘制标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM