给定三角形顶点的坐标,在 3D 中找到三角形面的法线角度 [英] Find the normal angle of the face of a triangle in 3D, given the co-ordinates of its vertices

查看:25
本文介绍了给定三角形顶点的坐标,在 3D 中找到三角形面的法线角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如您从 此屏幕截图中可以看出的,我正在尝试为我正在开发的平台游戏制作物理引擎,但我遇到了一个明确的问题:我需要能够找出构成这个网格的任何一个三角形的角度,这样我就可以计算出玩家在该三角形上的旋转和角加速度.

As you may be able to tell from this screenshot, I am trying to make a physics engine for a platformer I am working on, but I have run into a definite problem: I need to be able to find out the angle of any one of the triangles that you can see make up this mesh, so that I can work out the rotation and therefore angular acceleration of the player on that triangle.

我可以使用我创建的算法来查找玩家接触的任何三角形的所有 3 个点的位置,但我不知道如何使用这些点来计算三角形的旋转.

I can use an algorithm that I created to find the locations of all 3 points of any triangle that the player is in contact with, but I don't know how to use those points to work out the rotation of the triangle.

我所说的旋转是指法线远离面部中心的方向,即一个人站在那个表面上时倾斜的角度.有人能想出一系列方程来解决这个问题吗?

By the rotation, I mean the direction of the normal away from the centre of the face, i.e., the angle at which a person would be leaning if they stood on that surface. Can someone come up with a series of equations that will allow for this problem to be solved?

推荐答案

如果取两个向量的叉积:

If you take the cross product of the two vectors:

p1 - p0

p2 - p0

其中p0p1p2是三角形的三个顶点,你会得到法线.如果顶点相对于其向外的法线顺时针排列,则认为三角形指向您.这称为左手定则.想象一下握住左手,手指从 p0 卷曲到 p1,拇指朝面部法线方向伸出:

where p0, p1 and p2 are three vertices of the triangle, you'll get the normal. A triangle is considered to be pointing towards you if the vertices are ordered clockwise with respect to its outward normal. This is called the left hand rule. Imagine holding your left hand with your fingers curled from p0 to p1, your thumb sticks out in the direction of the face normal:

这篇关于给定三角形顶点的坐标,在 3D 中找到三角形面的法线角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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