找到第三点 [英] Find the third point

查看:85
本文介绍了找到第三点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2分P1P2.我需要找到P3,以便

I have 2 points P1 and P2. I need to find the P3, in order that

  • 所有点都在同一条线上;
  • P3应该与P2保持距离d(远离P1)
  • all points to be on the same line;
  • P3 should be at the distance d from the P2 (away from P1)

我启动了一个复杂的系统,显然很难解决...

I started a complicated system apparently hardly to resolve...

PS.

矢量答案很酷,但是我使用C#并且不知道如何在此处添加矢量.

Vectorial answers is cool, but I use C# and don't know how to add vectors over there.

推荐答案

P3 = P2 + d * ±(P2 - P1) / |P2 - P1|

因为购物很容易:

mag = sqrt((P2x - P1x) ** 2 + (P2y - P1y) ** 2)
P3x = P2x + d * (P2x - P1x) / mag
P3y = P2y + d * (P2y - P1y) / mag

这篇关于找到第三点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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