检查一个点是否在 3d 线上?
我知道如何检查一个点是否在 2d 线上,但我想在 3D 中执行此操作。有什么想法吗?
// slope from point 1 to point 3
var p13:Number = (Math.atan2 (end.x - start.x, end.y - start.y)) * toDegrees;
// slope from point 1 to point 2 -- matches?
var p12:Number = (Math.atan2 (point.x - start.x, point.y - start.y)) * toDegrees;
return Math.round(p12) == Math.round(p13);
I know how to check if a point is on a 2d line or not, but I'd like to do this in 3D. Any ideas?
// slope from point 1 to point 3
var p13:Number = (Math.atan2 (end.x - start.x, end.y - start.y)) * toDegrees;
// slope from point 1 to point 2 -- matches?
var p12:Number = (Math.atan2 (point.x - start.x, point.y - start.y)) * toDegrees;
return Math.round(p12) == Math.round(p13);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
标准化向量。检查法线是否匹配。
找到最大值,将所有其他值除以该值,得到法线向量。
直线上的任何点都应具有相同的法向量。
Normalize the vectors. Check if the normals match.
Find the greatest value, divide all of the other values by that value so you get a vector normal.
Any point on a line should have the same vector normal.
一个点永远不可能位于真实坐标中的一条线上。你需要做的是计算到距离线最近的点的距离,并决定是否这样做对你来说足够近了。
A point can never be 'on' a line in real coords. what you need to do is calculate the distance to the closest point to the line and decide if this is close enough for you.
直线的方程为
v(t) = v0 + t*dir
其中
v0
是直线上的某个点,dir
是直线的方向。只需检查您的点是否足够准确地匹配该线性方程The equation of a line is
v(t) = v0 + t*dir
Where
v0
is some point on a line anddir
is it's direction. Simply check if your point match this linear equation with enough accuracy