HUD2056 Rectangles

Rectangles

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 24963    Accepted Submission(s): 8116


Problem Description
Given two rectangles and the coordinates of two points on the diagonals of each rectangle,you have to calculate the area of the intersected part of two rectangles. its sides are parallel to OX and OY .
 

Input
Input The first line of input is 8 positive numbers which indicate the coordinates of four points that must be on each diagonal.The 8 numbers are x1,y1,x2,y2,x3,y3,x4,y4.That means the two points on the first rectangle are(x1,y1),(x2,y2);the other two points on the second rectangle are (x3,y3),(x4,y4).
 

Output
Output For each case output the area of their intersected part in a single line.accurate up to 2 decimal places.
 

Sample Input
1.00 1.00 3.00 3.00 2.00 2.00 4.00 4.00 5.00 5.00 13.00 13.00 4.00 4.00 12.50 12.50
 

Sample Output
1.00 56.25
给定两个矩形和每个矩形对角线上两个点的坐标,您必须计算两个矩形的相交部分的面积。其侧面与OX和OY平行。
 输入第一行输入是8个正数,表示必须在每个对角线上的四个点的坐标。8个数字是x1,y1,x2,y2,x3,y3,x4,y4。
这意味着第一个矩形上的两个点是(x1,y1),(x2,y2);第二个矩形上的另外两个点是(x3,y3),(x4,y4)。
输出对于每个案例,它们将相交部分的区域,占一行。最多可以存放2位小数。
将两个矩形的宽(x轴)相加,长(y轴)相加,在分别减去投影到x轴线段的长度,投影到y轴线段的长度,判断两矩形是否有重合部分(
if(n<0||m<0) area = 0;)没有重合,area = 0。否则,area = n * m;输出area即可。

代码如下:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
	double m,n,area;
    double x1,x2,x3,x4,y1,y2,y3,y4,a[4],b[4]; 
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4)
	{
		a[0] = x1,a[1] = x2, a[2] = x3, a[3] = x4;
		b[0] = y1, b[1] = y2, b[2] = y3, b[3] = y4;
		sort(a,a+4),sort(b,b+4);
		m = fabs(x1 - x2) + fabs(x3 - x4) - (a[3] - a[0]);
		n = fabs(y1 - y2) + fabs(y3 - y4) - (b[3] - b[0]);
		if(n<0||m<0) area = 0;
		else area = n * m;
		printf("%.2lf\n",area);
	}
	return 0;
}


现有技术中,典型车辆安全辅助系统的结构如下(参考图1,需补充附图): 传感器层:单毫米波雷达(前向)+ 摄像头(前向),仅采集前向车辆数据; 数据处理层:基于固定阈值算法计算前向碰撞风险,未整合后向传感器数据; 人机交互层:单一声音报警或仪表盘灯光提醒,缺乏多模态协同。 其工作原理为:通过前向传感器获取前车距离 df, df 和速度 vf ,若 df <ds(固定阈值100米),则触发报警。对于后向车辆接近或前后同时有大型车辆包夹的场景,现有系统无法识别,因未配置后向传感器且缺乏多方向数据融合逻辑。 优化UML编码 @startuml !pragma layout disable title 前向碰撞预警系统架构 skinparam rectangle { BackgroundColor #FFFFFF BorderColor #000000 ArrowColor #800000 FontName "Arial" FontSize 12 } rectangle "前向碰撞预警系统" as system { rectangle "前向传感器层" as sensor_layer { rectangle "毫米波雷达(77GHz)\n单目摄像头(120° FOV)\n探测距离:0-200m" as sensor } rectangle "信号处理单元" as processor_layer { rectangle "目标追踪算法\n碰撞时间(TTC)计算\n决策阈值:TTC\<2.5s" as processor } rectangle "预警执行器" as actuator_layer { rectangle "声学报警(蜂鸣器)\n光学报警(HUD显示)\n触觉反馈(方向盘震动)" as actuator } ' 数据流连接 sensor --> processor : 原始感知数据\n(距离/速度/角度) processor --> actuator : 预警指令\n(危险等级) } ' 系统注释 note top of sensor <b>硬件接口</b>: CAN总线 <b>采样频率</b>: 100Hz end note note right of processor <b>处理延迟</b>: \<50ms <b>算法版本</b>: v2.3 end note note bottom of actuator <b>预警强度</b>: 3级可调 <b>反馈方式</b>: 声+光+触觉 end note @enduml 不需要详细的传感器参数,只需要大概的系统结构图,表显出前车距离 df, df 和速度 vf ,若 df <ds(固定阈值100米),则触发报警即可。突出对于后向车辆接近或前后同时有大型车辆包夹的场景,现有系统无法识别,因未配置后向传感器且缺乏多方向数据融合逻辑
08-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值