C# - 如何检查对象是否在椭圆等有限区域内?

发布于 2025-01-15 18:35:28 字数 338 浏览 3 评论 0原文

我有一个定义的椭圆形状,但是,无法弄清楚如何检查目标/对象是否位于该椭圆区域内。

例如,这就是我抓取定义的圆形物体的方法。在Unity中...

Collider2D[] targetsInRadius = Physics2D.OverlapCircleAll(Circle.position, Radius, targetMask);

这只有效,因为圆有一个半径,但是椭圆有两个半径,其中一个比另一个长。 unity 是否有与上面的省略号代码相同的东西。

如果有帮助的话,我有一个包含定义椭圆形状的顶点/线段的 Vector3 数组。
如何检查目标是否在椭圆内?

I have a defined ellipse shape, however, can't figure out how to check if a target/object is within this ellipse area.

For example this is what I did to grab objects in defined circle shape. In Unity...

Collider2D[] targetsInRadius = Physics2D.OverlapCircleAll(Circle.position, Radius, targetMask);

This only works because circles have a single Radius, However ellipse has two radius where one is longer than the other. does unity have something equivalent to the above code for ellipses.

If it helps I have a Vector3 array containing the vertexes/segment defining the ellipse shape.
how do I check if target is within ellipse?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文