点相对于贝塞尔曲线的位置 [英] Position of a point relative to a Bezier curve

查看:29
本文介绍了点相对于贝塞尔曲线的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一条由 4 个点指定的贝塞尔曲线.我需要知道一个点是在贝塞尔曲线的左侧还是右侧.能给我推荐一个算法吗?

I have a Bezier curve specified by 4 points. I need to know if a point is on the left side or right side of the Bezier curve. Can you suggest me an algorithm?

我确定我生成的方式贝塞尔曲线不会形成循环.

I'm sure that the way I generate the Bezier curve would not form loops.

稍后编辑 我意识到我最初的问题可以在不使用相对位置的情况下解决.当我发布这个问题时,我在想有一个相对位置的数学公式,类似于检查一个点是否在圆的内部.似乎这是不可能的.所以我会接受答案,这将提出一个省时的解决方案.

Later edit I realized that my initial problem could be solved without using relative position. When I posted this question I was thinking that there is a mathematical formula for relative position similarly with checking if a point is in the interior of a circle. It seems that this is not possible. So I will accept the answer which will suggest a time efficient solution.

推荐答案

您可以使用非常简单的算法(与 k-subdivision.DeCastleju's Algorithm 相关)确定贝塞尔曲线上的最近点.需要细节.

You can determine the closest point on the bezier curve with a pretty straightforward algorithm (related to k-subdivision. DeCastleju's Algorithm.) Look at the graphics gems if you need specifics.

此时,即使使用循环,您也可以通过确定从最近点到测试点的向量是否位于沿曲线行进的向量的左侧(速度? - 不是确定此处的正确术语...)您确定的最近点的贝塞尔曲线.

At that point, even with loops, you can determine side-ness by determining if the vector to your tested point from the closest point is on the left of right hand of the vector that goes along the curve (velocity? - not sure of the correct term here...) of the bezier at the closest point you determined.

您可以通过两个向量的叉积来获得 -that-.消极或积极将决定你的左手习惯和你在哪一边.

You can get -that- by cross product of the two vectors. Negative or positive will determine the handedness and which side of the line you are on.

当然,在一个循环中,侧向性将被定义为好像你是一辆沿着线路行驶的汽车,当你经过时你是在看右边还是左边的窗户……如果你要整个贝塞尔曲线的右侧或左侧.所以这取决于你如何定义sideness"

Of course, in a loop the sideness will be defined as if you were a car driving down the line, would you be looking out the right or left window at the point as you go by... Not if you are to the right or left of the whole bezier squiggle. So it depends on how you define "sideness"

对不起,如果我的条款不适用.自从我不得不对 Bezier 做任何事情以来已经有一段时间了

Sorry if my terms are off. Its been awhile since I had to do anything with Bezier's

画一幅画会更容易;)

这篇关于点相对于贝塞尔曲线的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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