http://stackoverflow.com/questions/7328424/point-in-obb-oriented-bounding-box-algorithm

Given a center point, width, height and angle forming an OBB, how can I find if a given point P is inside the OBB?

I take it that the wrinkle in your problem is that the bounding box can be rotated? If so, the easiest solution to me seems to be to do all calculations in the rotated coordinate plane, centered on the center of the bounding box.

To calculate the coordinates of the point relative to these axes:

newy = sin(angle) * (oldy - centery) + cos(angle) * (oldx - centerx);
newx = cos(angle) * (oldx - centerx) - sin(angle) * (oldy - centery);

(you may need to adjust this depending on how angle is supposed to be measured, I'll leave that to you, since you didn't specify)

Then hit test, the normal way:

return (newy > centery - height / 2) && (newy < centery + height / 2)
&& (newx > centerx - width / 2) && (newx < centerx + width / 2);

判断2D平面内某点是否在某个旋转的矩形(OBB)内的算法的更多相关文章

  1. UI3D转2D平面显示UI3DTo2D血条显示

    UI3D转2D平面显示UI3DTo2D血条显示: using UnityEngine; using System.Collections; public class UI3DTo2D : MonoBe ...

  2. 盒子显隐,伪类边框,盒子阴影,2d平面形变

    -盒子显隐 显隐的盒子尽量不影响其他盒子的布局 display:none; 消失的时候不占位置,显示的时候占位 opacity:0-1; 盒子透明度 overflow: hidden; 超出部分隐藏 ...

  3. Android判断一个点是否在矩形区域内

    个人遇到的问题判断按钮的点击事件还是滑动事件 private boolean button1Down = false; private boolean button2Down = false; pri ...

  4. threeJS创建mesh,创建平面,设置mesh的平移,旋转、缩放、自传、透明度、拉伸

    这个小案例是当初我在学习的时候,小的一个小案例,代码还需要进一步优化:还请谅解~~:主要用到了threeJS创建mesh,创建平面,设置mesh的平移,旋转.缩放.自传.透明度.拉伸等这些小功能: 采 ...

  5. 查询矩形范围内的"点"要素

    步骤 1,首先在含有主视图控件 ESRI.ArcGIS.Controls.AxMapControl mapCtrl_main 的主类中定义一个 IEnvelope 成员变量,用于记录鼠标在主视图控件画 ...

  6. Help Hanzo lightof 1197 求一段区间内素数个数,[l,r] 在 [1,1e9] 范围内。r-l<=1e5; 采用和平常筛素数的方法。平移区间即可。

    /** 题目:Help Hanzo lightof 1197 链接:https://vjudge.net/contest/154246#problem/M 题意:求一段区间内素数个数,[l,r] 在 ...

  7. 行内元素与块级元素的区别,行内块级元素在IE8-的兼容性

    行内元素与块级元素的区别 行内元素最好不要包裹块级元素,但是块级元素可以任意的包裹行内元素 行内元素如果其上一个元素也是行内元素,则他们会分布在统一水平线上,即在一行上排列,块级元素不论上一个元素是行 ...

  8. p2p-tunnel 打洞内网穿透系列(三)TCP转发访问内网web服务

    系列文章 p2p-tunnel 打洞内网穿透系列(一)客户端配置及打洞 p2p-tunnel 打洞内网穿透系列(二)TCP转发访问远程共享文件夹 p2p-tunnel 打洞内网穿透系列(三)TCP转发 ...

  9. p2p-tunnel 打洞内网穿透系列(二)TCP转发访问内网共享文件夹

    系列文章 p2p-tunnel 打洞内网穿透系列(一)客户端配置及打洞 p2p-tunnel 打洞内网穿透系列(二)TCP转发访问远程共享文件夹 p2p-tunnel 打洞内网穿透系列(三)TCP转发 ...

随机推荐

  1. 2D多边形碰撞器优化器

    http://www.unity蛮牛.com/thread-19827-1-1.html http://pan.baidu.com/s/1qW2mWS8 Asset Store Link: http: ...

  2. Spring+MyBatis实践—工程配置

    初次实践:Spring+MyBatis技术搭建框架,采用Bootstrap前端开源框架. 简介: MyBatis是支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis 消除 了几乎所 ...

  3. CF192div2-C - Purification

    题意: 从给定的图中找出某些点,这些点能够消除同一行和同一列的“怪物”.求使得最少的点的位置. 关键:要想消除整张的图的妖怪,必须选中n个点(对于n行n列来说)!!!!!!!!!!! 做法:对于每一行 ...

  4. php smarty section使用

    文件:section.tpl <html> <head> <title></title> </head> <body> {sec ...

  5. HDOJ多校联合第六场

    先一道一道题慢慢补上, 1009.题意,一棵N(N<=50000)个节点的树,每个节点上有一个字母值,给定一个串S0(|S0| <=30),q个询问,(q<=50000),每次询问经 ...

  6. [jobdu]数组中出现次数超过一半的数字

    找到以后要再扫一遍确认. http://zhedahht.blog.163.com/blog/static/25411174201085114733349/ #include <iostream ...

  7. SPRING IN ACTION 第4版笔记-第七章Advanced Spring MVC-002- 在xml中引用Java配置文件,声明DispatcherServlet、ContextLoaderListener

    一.所有声明都用xml 1. <?xml version="1.0" encoding="UTF-8"?> <web-app version= ...

  8. C# ASP.NET FILEUPLOAD详解

    显示一个文本框控件和一个浏览按钮,使用户可以选择要上载到服务器的文件. 命名空间: System.Web.UI.WebControls 程序集: System.Web(在 system.web.dll ...

  9. 修改tomcat的部署名称

    找到指定工程下面的.setting目录下面的org.eclipse.wst.common.component文件,可以看到以下的配置 <?xml version="1.0" ...

  10. 下拉列表联动显示(Car表) 三级联动

    .Models namespace 下拉列表联动显示_Car表_.Models { public class ProductorBF { private MyDBDataContext _contex ...