压扁了3D三角 [英] Flattening a 3d triangle

查看:252
本文介绍了压扁了3D三角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个函数,它接受一个三维三角形(如3点(vector3ds)),并返回一个2D的三角形(如3点(vector2ds)):

I would like to write a function that takes a 3d triangle (as 3 points (vector3ds)) and returns a 2d triangle (as 3 points (vector2ds)):

在给定的三维三角形,它应该为他们趴在它的飞机返回了点二维坐标。 (由其平面我的意​​思是,所有这三个点都在飞机上)。

When given a 3d triangle, it should return the 2 dimensional coordinates of its points as they lie on its plane. (By 'its plane' I mean the plane that all three points lie on).

我能想到一个长篇大论办法TODO这样的:

I can think a long winded way todo this:

  • 旋转三角形直到其正常等于+ Z(0,0,1),然后构造从(X,Y)一个三角形的每个点的的coords。

我不能帮助,但认为必须有一个更简单的方法来达到同样的事情。

I cant help but think there must be an easier way to achieve the same thing.

如果张贴code的例子,请尽量不要用希腊字母。一些伪code在C / Java的语言风格将是理想的。

推荐答案

从您的意见我推断你可以选择坐标平面系统中的任意方法,只要该欧氏度量的坐标系是一样的为引起您的三维坐标系的欧氏度量指标。 (即,欧几里德距离将保持不变。)

From your comments I infer that you can choose the coordinate system of the plane in an arbitrary way, as long as the Euclidean metric of this coordinate system is the same as the metric induced by the Euclidean metric of your three-dimensional coordinate system. (That is, Euclidean distances will stay the same.)

一个可行的办法:

x0' = 0
y0' = 0

x1' = sqrt((x1 - x0)^2 + (y1 - y0)^2 + (z1 - z0)^2)
y1' = 0

x2' = ((x1 - x0) * (x2 - x0) + 
       (y1 - y0) * (y2 - y0) + 
       (z1 - z0) * (z2 - z0)) / x1'
y2' = sqrt((x2 - x0)^2 + (y2 - y0)^2 + (z2 - z0)^2 - x2'^2)

这篇关于压扁了3D三角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆