找到2点之间的限制点

发布于 2024-12-11 12:02:18 字数 684 浏览 0 评论 0 原文

  • 我有 A 点和另一个点(如 B、C 或 D)的坐标。
  • 我还有 A 到另一点之间的距离。
  • 我知道 A 和另一点之间的最大允许距离(用紫色线和假想圆表示)。
  • 问题:如何找到红点(B1 或 C1 或 D1)的坐标。
  • 示例:A=(-1,1), E=(3,-8),最大允许距离 = 4。E1 点的坐标是多少?

这是问题的图像: 问题

注意: 我发现了另外两个非常相似或相同的问题,但我无法解决这些问题: 查找两点之间的点的坐标?

如何我可以仅使用线段的部分长度找到放置在形成线段的 2 个点之间的点吗?

PS 这不是作业,我需要这个来解决编程问题,但我忘记了数学...

  • I have the coordinate of point A and another point (like B, C or D).
  • I also have the distance between A and the other point.
  • I know the maximum allowed distance between A and the other point (illustrated with the purple line and the imaginary circle).
  • Question: How do I find the coordinates of the red points (B1 or C1 or D1).
  • Example: A=(-1,1), E=(3,-8), Max allowed distance = 4. What is the coordinate of point E1?

Here is an image of the problem:
problem

Note:
I found 2 other questions that are pretty similar or equal but I'm not able to work it out with those:
Finding coordinates of a point between two points?

How can I find a point placed between 2 points forming a segment using only the partial length of the segment?

P.S. This is not homework I need this for a programming problem but I forgot my Maths...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

要走干脆点 2024-12-18 12:02:18

假设 A 是位置向量,B 是位置向量,maxLength 是允许的最大长度。

ABVector2(正如您标记此问题)。

// Create a vector that describes going from A to B
var AtoB = (B - A);
// Make a vector going from A to B, but only one unit in length
var AtoBUnitLength = Vector2.Normalize(AtoB);
// Make a vector in the direction of B from A, of length maxLength
var AtoB1 = AtoBUnitLength * maxLength;
// B1 is the starting point (A) + the direction vector of the
// correct length we just created.
var B1 = A + AtoB1;

// One liner:
var B1 = A + Vector2.Normalize(B - A) * maxLength;

Assuming A is a position vector, B is a position vector, and maxLength is the max length you're allowing for.

A and B are Vector2's (as you tagged this question ).

// Create a vector that describes going from A to B
var AtoB = (B - A);
// Make a vector going from A to B, but only one unit in length
var AtoBUnitLength = Vector2.Normalize(AtoB);
// Make a vector in the direction of B from A, of length maxLength
var AtoB1 = AtoBUnitLength * maxLength;
// B1 is the starting point (A) + the direction vector of the
// correct length we just created.
var B1 = A + AtoB1;

// One liner:
var B1 = A + Vector2.Normalize(B - A) * maxLength;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文