计算笛卡尔空间中的偏移坐标

发布于 2025-01-17 02:08:19 字数 246 浏览 5 评论 0原文

如果我有2个坐标点A(x,y)和点B(x,y),

我需要计算特定距离和角度90度和270度的偏移坐标。 我该怎么办?

找不到正确的公式。

如何获取C、D、E、F的坐标?

pic

if I have 2 coordinate pointA(x,y) and pointB(x,y)

I need to calculate the offset coordinate at specific distance and angle 90 deg and 270 deg.
How can I?

Can't find the right formula.

How to get the coordinate of C,D,E,F?

pic

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

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

发布评论

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

评论(1

极致的悲 2025-01-24 02:08:19

差异向量

dx = B.X - A.X
dy = B.Y - A.Y

垂直向量

px = -dy
py = dx

向量长度(也许你的数学库中有现成的函数 Hypot 或类似函数)

len = sqrt(px*px+py*py)

归一化(单位长度)向量

nx = px / len
ny = py / len

现在找到距离 dist 处的点:

C.X = A.X + nx * dist
C.Y = A.Y + nY * dist

G.X = A.X - nx * dist
G.Y = A.Y - nY * dist

类似于B 周围的点

Difference vector

dx = B.X - A.X
dy = B.Y - A.Y

Perpendicular vector

px = -dy
py = dx

Vector length (perhaps you have ready function Hypot or alike function in your math library)

len = sqrt(px*px+py*py)

Normalized (unit length) vector

nx = px / len
ny = py / len

Now find points at distance dist:

C.X = A.X + nx * dist
C.Y = A.Y + nY * dist

G.X = A.X - nx * dist
G.Y = A.Y - nY * dist

similar for points around B

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文