算法用于反射穿过线上的点 [英] Algorithm for reflecting a point across a line

查看:120
本文介绍了算法用于反射穿过线上的点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定的点(X1,Y1)和公式为一条线(表达式y = mx + c)中,我需要一些伪code,用于确定点(X2,Y2),它是第一个点的反射跨线。花了大约一个小时试图数字出来,没有运气!

Given a point (x1, y1) and an equation for a line (y=mx+c), I need some pseudocode for determining the point (x2, y2) that is a reflection of the first point across the line. Spent about an hour trying to figure it out with no luck!

在这里看到一个可视化 - <一个href="http://www.analyzemath.com/Geometry/Reflection/Reflection.html">http://www.analyzemath.com/Geometry/Reflection/Reflection.html

See here for a visualization - http://www.analyzemath.com/Geometry/Reflection/Reflection.html

推荐答案

好吧,我去给你一本食谱的方法来做到这一点。如果你有兴趣我是如何得出的,告诉我,我会解释。

Ok, I'm going to give you a cookbook method to do this. If you're interested in how I derived it, tell me and I'll explain it.

由于(X,Y)和行 Y = AX + C 我们想要的点(X',Y')反映就行了。

Given (x,y) and a line y = ax + c we want the point (x', y') reflected on the line.

设置 D:=(X +(Y - C)* A)/(1 + A ^ 2)

然后 X'= 2 * D - X

Y'= 2 * D * A - Y + 2C

这篇关于算法用于反射穿过线上的点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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