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

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

问题描述

我有一个由4点指定的贝塞尔曲线。我需要知道一个点是在贝塞尔曲线的左边还是右边。你可以给我一个算法吗?



编辑:我确定我生成贝塞尔曲线的方式不会形成循环。



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

解决方案

您可以确定贝塞尔曲线上的最近点一个非常简单的算法(与k-subdivision相关。DeCastleju算法)。如果你需要细节,看看图形宝石。



此时,即使有循环,您也可以通过确定从最近点开始测试的点的矢量是否在左边的左侧来确定边界在你确定的最接近的点上沿着曲线(速度? - 不确定这里的正确术语......)的矢量。

您可以通过两个向量的交叉乘积来获得-that-。否定的或积极的将决定你的习惯和你在哪一方。

当然,在一个循环中,侧面的定义就好像你是一辆开着车的车一样,你会在这个点看右边或左边的窗户当你走过......如果你在整个贝塞尔曲线的左边或右边,则不是。所以这取决于你如何定义侧面



很抱歉,如果我的条款关闭。它已经有一段时间了,因为我不得不做任何事情Bezier的



绘制图片会更容易;)


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?

Edit: 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.

解决方案

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.

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.

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"

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

It would be easier to draw a picture ;)

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

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