public static bool isLineIntersectRectangle(float linePointX1,
float linePointY1,
float linePointX2,
float linePointY2,
float rectangleLeftTopX,
float rectangleLeftTopY,
float rectangleRightBottomX,
float rectangleRightBottomY)
{
float lineHeight = linePointY1 - linePointY2;
float lineWidth = linePointX2 - linePointX1; // 计算叉乘
float c = linePointX1 * linePointY2 - linePointX2 * linePointY1;
if ((lineHeight * rectangleLeftTopX + lineWidth * rectangleLeftTopY + c >= 0 && lineHeight * rectangleRightBottomX + lineWidth * rectangleRightBottomY + c <= 0)
|| (lineHeight * rectangleLeftTopX + lineWidth * rectangleLeftTopY + c <= 0 && lineHeight * rectangleRightBottomX + lineWidth * rectangleRightBottomY + c >= 0)
|| (lineHeight * rectangleLeftTopX + lineWidth * rectangleRightBottomY + c >= 0 && lineHeight * rectangleRightBottomX + lineWidth * rectangleLeftTopY + c <= 0)
|| (lineHeight * rectangleLeftTopX + lineWidth * rectangleRightBottomY + c <= 0 && lineHeight * rectangleRightBottomX + lineWidth * rectangleLeftTopY + c >= 0))
{
if (rectangleLeftTopX > rectangleRightBottomX)
{
float temp = rectangleLeftTopX;
rectangleLeftTopX = rectangleRightBottomX;
rectangleRightBottomX = temp;
}
if (rectangleLeftTopY < rectangleRightBottomY)
{
float temp1 = rectangleLeftTopY;
rectangleLeftTopY = rectangleRightBottomY;
rectangleRightBottomY = temp1;
}
if ((linePointX1 < rectangleLeftTopX && linePointX2 < rectangleLeftTopX)
|| (linePointX1 > rectangleRightBottomX && linePointX2 > rectangleRightBottomX)
|| (linePointY1 > rectangleLeftTopY && linePointY2 > rectangleLeftTopY)
|| (linePointY1 < rectangleRightBottomY && linePointY2 < rectangleRightBottomY))
{
return false;
}
else
{
return true;
}
}
else
{
return false;
}
}
C++ 判断线段和矩形是否相交
详细解析竞业限制
竞业限制是指用人单位在劳动合同或者保密协议或者竞业限制协议中,与掌握本单位商业秘密和与知识产权相关的保密事项的劳动者约定,在劳动合同解除或者终止后的一定期限内,不得到与本单位生产或者经营同类产品、从事同类业务的有竞争关系的其他用人单位任职,也不得自己开业生产或者经营同类产品、从事同类业务。
浏览器 STATUS_INVALID_IMAGE_HASH 错误状态码解决办法
解决方法:
- 打开注册表
- 进入\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome(Policies没有Google和Chrome就新建项)
- 然后新建DWORD(32位),将名称改为RendererCodeIntegrityEnabled,值为0
重启浏览器问题解决。
如何面试程序员
提问之前的准备
首先,最重要的是,你自己一开始就应该想清楚:
- 需要新员工完成什么样的任务?
- 怎样的人能完成这样的任务?
- 哪些途径和方法可以发现这样的人?
只有明确这些根本性的问题,才能正确高效地完成面试。
硅谷公司是如何培训面试官的
编程篇
面试就好像是在第一次约会的时候就要决定是不是要结婚
这是一个真实的笑话。在每日高强度的工作当中,我们和一些同事相处的时间甚至会比家人还要长。所以面试是工作中十分重要的一个环节。
陪你骑车好吗 - 驻马店浮沉
陪你骑车好吗 - 买了辆PUKY
前端工程师简史
互联网的飞速发展,催生了很多高薪职业,程序员便是其中佼佼者。
在程序员群体中,前端岗位以其门槛低(相对其他技术岗位)、工资高(相对非互联网行业)、发展好(薪酬涨幅高)受到广大有为打工人的青睐。
陪你骑车好吗 - 再也不想去宜昌了
C++ Boost中的signals2的使用
signals2基于Boost的另一个库signals,实现了线程安全的观察者模式。在signals2库中,观察者模式被称为信号/插槽(signals and slots),他是一种函数回调机制,一个信号关联了多个插槽,当信号发出时,所有关联它的插槽都会被调用。