简体   繁体   English

Java中的3D转换

[英]3D Transformation in Java

I have to write a program which draws lots of triangles. 我必须编写一个绘制许多三角形的程序。 I have got 3D-coordinates but I want to draw them in 2D. 我有3D坐标,但我想以2D绘制它们。 My problem is that I am not understanding how I can transform the coordinates and the websites I found never had got an example, so eg I got A(3|1.5|-0.5), B(4|2.5|-1) & C(5|1|-1.5) and I am standing ad ViewingPoint(4|2|10). 我的问题是我不了解如何变换坐标,发现的网站从来没有一个例子,例如,我得到了A(3 | 1.5 | -0.5),B(4 | 2.5 | -1)和C (5 | 1 | -1.5),我站在ViewingPoint(4 | 2 | 10)上。 What are the new coordinates and how I get them? 什么是新坐标,我如何获得?

Basically, you would do this like that : 基本上,您可以这样做:

u = x/z; //u is your x in 2D
v = y/z; //v is your y in 2D
  • u and v are your new coordinates in 2D for a specific point u和v是您在2D中特定点的新坐标
  • and x, y and z are your old 3D coordinates for that point x,y和z是该点的旧3D坐标

I am adding this link to my answer as this is the math behind my answer : https://en.wikipedia.org/wiki/3D_projection?oldformat=true 我将此链接添加到我的答案中,因为这是我的答案背后的数学公式: https : //en.wikipedia.org/wiki/3D_projection?oldformat=true

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

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