简体   繁体   English

如何在3D三角形的给定点(x,z)上找到y?

[英]How to find y at given point (x,z) on 3D triangle?

In a coordinate system where y is up/down, z is forward/backwards, x is left/right (as in Unity3D). 在y为上/下,z为前/后,x为左/右的坐标系中(与Unity3D相同)。


(Here's a bad drawing of what I mean) (这是我意思的不好描述)

y ÿ
| |
| | _ __ _x _ __ _x
\\ \\
z ž

(z would be going into/out of your monitor I guess) (我想z会进入/离开您的显示器)


Given coordinate (x,z) that is guaranteed to be on this triangle, how would I get y? 给定坐标(x,z)保证在这个三角形上,我将如何获得y? Assume that you know the (x,y,z) coordinates of all three triangle points, as well as the normal of the face. 假设您知道所有三个三角形点的(x,y,z)坐标以及人脸的法线。 The triangle may be slanted on any axis. 三角形可以在任何轴上倾斜。

Well, given any Vector v inside your triangle, and your normal n , we know that the dot product of n and v equals 0 (true for all points on the triangle). 好吧,给定三角形内的任何向量v以及法线n ,我们知道nv的点积等于0(对于三角形上的所有点均为true)。 So: 所以:

nx * vx + ny * vy + nz * vz = 0

Little algebra to solve for vy and we have: 解决vy小代数,我们有:

vy = -((nz * vz) + (nx * vx)) / ny

One thing though. 一件事。 v must be in the plane of your triangle, so you will need to put that vector in the plane of your triangle, by subtracting one of your vertices (say t1 ) from v . v必须在三角形的平面内,因此您需要通过从v减去一个顶点(例如t1 ),将矢量放入三角形的平面内。

So: 所以:

vx = t1x - x, vz = t1z - z, and vy = t1y - y

And therefore, your final y coordinate is: y = t1y - vy where vy is defined above. 因此,最终的y坐标为: y = t1y - vy其中vy在上面定义。

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

相关问题 如何在WPF中绘制XYZ 3D动画? - how to draw X Y Z 3D animation in WPF? 检查对象碰撞c#:3D(XYZ) - Check collision of objects c# : 3D (X Y Z) 旋转矩阵给定角度和X,Y,Z点 - Rotation Matrix given angle and point in X,Y,Z 如何在 xna 程序中从 3d Max 获取 3D 模型的位置(x,y,z) - How can I get the position(x,y,z) of a 3D Model from 3d Max in xna program 如何使用HelixToolkit用3轴XYZ旋转3D模型? - How to rotate 3D model with 3 axis X Y Z using HelixToolkit? 如何在给定点找到最近点(点(x,y),在不同点的列表中)? - How to find closest point (point being (x,y), in a list of different points) to a given point? 如何在围绕原点旋转的 3D 网格中为任何给定点找到最近的网格点? - How to find the closest grid point, for any given point, in a 3D grid that has been rotated around the origin? 使用距原点的距离作为第三个参数,确定由两个 3D 点定义的线上任意点的 x、y、z 坐标? - Determine the x,y,z coordinates of any point on a line defined by two 3D points using distance from origin-point as the third parameter? 如何找到给定方向向量和向上向量的x,y和z旋转角度? - How to find the x, y and z rotational angles for the given directional vector and up vector? Unity 3D中如何将对象移动到鼠标的z和y坐标 - How to move objects to the z and y coordinates of the mouse in Unity 3D
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM