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

问题描述

我想编写一个函数,它接受一个 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)):

当给定一个 3d 三角形时,它应该返回其点位于其平面上时的二维坐标.(它的平面"是指所有三个点所在的平面).

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).

我可以想到一个冗长的方法来做到这一点:

I can think a long winded way todo this:

  • 旋转三角形直到其法线等于 +z (0,0,1),然后根据每个点的 (x, y) 坐标构造一个三角形.

我不禁认为必须有一种更简单的方法来实现同样的目标.

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

如果发布代码示例,请尽量不要使用希腊字母.一些 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 三角形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 02:46