问题标签 [bounding-box]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
693 浏览

google-maps - 谷歌地图 KM 边界框在地图缩放中重新应用

我有一张地图,在其中我使用KMbox叠加应用自定义叠加来表示我认为用户的一般兴趣点所在的位置。我想要的是向用户显示这张地图,并允许他们点击地图给我他们的 POI 的精确位置匹配。

这一切都很好,除了当用户点击地图并改变地图的缩放比例。

这是我将标记添加到地图的代码。

为了显示地图,我有这个功能。

我在以下链接中有一个工作示例

0 投票
2 回答
2690 浏览

c# - 如何跨多个网格计算边界框/球体(C#)

我从不同网格变量中的 .x 文件加载多个网格。现在我想计算我已加载(以及正在显示的)所有网格的边界球体,请指导我如何实现这一点。可以将 VertexBuffers 添加到一个变量中并使用该变量计算 boundingSphere 吗?(如果是的话,他们是如何将 vertexBuffers 添加在一起的)否则你会建议什么替代方案!?谢谢

0 投票
2 回答
7065 浏览

javascript - 获取相对于窗口的 HTML 元素的边界框的正确方法是什么?

我正在写一个 Firefox 扩展。我试图将其限制为 XUL+Javascript(没有 XPCOM)。当我得到一个mouseoverHTML 元素的事件时,我需要在 windows 坐标系中获取它的边界框(即内置的 XUL 文档 browser.xul)。

显而易见的起点是在 mouseover 事件处理程序中放置类似这样的内容:

这很好,但这给了我 HTML 文档坐标系中的 rect,它是相对于 HTML 绘图区域的左上角的。我想在此图像附近使用 panel.openPopup() 显示 xul:panel 元素(但不使用预定义的弹出位置之一),因此我需要转换坐标。

我已经尝试执行以下操作(在 XUL dom 中)以获取偏移量来进行翻译,它适用于某些网站,但不是全部,并且似乎没有考虑到侧边栏所需的 x 翻译。

那么,解决这个问题的最佳方法是什么?

注意:对于 IE 扩展,我会使用(并且已经使用)IDisplayServices::TransformRect() — Firefox 有类似的东西吗?

现在有赏金!

0 投票
3 回答
9904 浏览

google-maps - 在 Google Maps API v3 中获取折线的边界

有没有使用 Google Maps API v3 找到折线边界框的简单方法?我正在开发一个项目,我需要在地图中添加和删除数据时更新边界。这很简单,只需执行 bd.extend(point) 即可,其中 bd 是绑定对象,point 是 LatLng 对象。问题是当我开始删除数据时,我希望它改变边界并重新放大。是否有任何内置函数可以做到这一点,或者我需要为自己写一些东西?

0 投票
1 回答
816 浏览

java - 如何获得转换后的文本(java)的边界框?

目前我有一个文本对象,我需要确定它的边界。我曾经使用图形对象来获取我要绘制的文本的字体度量,但是由于我添加了旋转对象的功能(可能还有更多),我需要一种更好的方法来获取该对象的边界。我已经看过多个地方,但到目前为止还没有什么对我有用。这是我最近的尝试:

这是获取转换文本边界框的正确方法吗?

0 投票
1 回答
2640 浏览

algorithm - Pseudocode for Swept AABB Collision

I think swept means determining if objects will collide at some point, not just whether they are currently colliding, but if I'm wrong tell me.

I have objects with bounded boxes that are aligned on an axis. The boxes of objects can be different sizes, but they are always rectangular.

I've tried and tried to figure out an algorithm to determine if two moving AABB objects will collide at some point, but I am having a really hard time. I read a question on here about determining the time intervals when the two objects will pass at some point, and I didn't have a problem visualizing it, but implementing it was another story. It seems like there are too many exceptions, and it doesn't seem like I am doing it correctly.

The objects are only able to move in straight lines (though obviously they can change direction, e.g. turn around, but they are always on the axis. If they try to turn off the axis then it just doesn't work), and are bound to the axis. Their bounded boxes don't rotate or do anything like that. Velocity can change, but it doesn't matter since the point of the method is to determine whether, given the objects' current state, they are on a "collision course". If you need any more information let me know.

If someone could provide some pseudocode (or real code) that would be great. I read a document called Intersection of Convex Objects: The Method of Separating Axes but I didn't understand some of the pseudocode in it (what does Union mean)?

Any help is appreciated, thanks.

0 投票
1 回答
291 浏览

actionscript-3 - Actionscript getBounds : 如果 targetCoOrdinateSpace 没有添加到阶段怎么办

我有两个显示对象 dispObj1、dispObj2。
dispObj2.stage为空。(即无论如何都不会添加到舞台)dispObj1.getBounds(dispObj2)
的输出应该是什么? 它是明确定义的,还是可以任意的? 一旦我得到x 的 boundingRectangle接近6710785,我猜这 是某处整数溢出的症状。


但其他时候我得到了一个合理的 x,y,width,height 值。

0 投票
7 回答
76335 浏览

android - 如何在 Android 上获取字符串宽度?

如果可能的话,我也想获得身高。

0 投票
2 回答
695 浏览

c++ - 2D边界框碰撞

在我正在编写的一个小型 2D 游戏中,我遇到了一些碰撞问题。我目前正在研究一个函数,我想查找玩家角色是否与块碰撞,以及他与块的哪一侧发生碰撞。

目前我有类似(伪代码):

我这里有一些逻辑错误吗?还是我只是在我的代码中写错了什么?

ABOVE 碰撞有效,但它不应该识别侧面碰撞,有时它不应该识别侧面碰撞。

该游戏是 SuperMario 的克隆版,因此它是一款横向卷轴 2D 平台游戏。

0 投票
1 回答
369 浏览

python - Python:如何知道 PIL 中的边界框中有多少种颜色?

嘿,我有这么多 PIL 边界框(x,y,x1,y1)

我只想知道边界框有多少种颜色,有什么快速的方法吗?