UVALive 7292 Refract Facts(二分法)

本文介绍了一种通过二分法求解潜艇使用激光通讯时,针对空中目标所需调整的激光发射角度的方法。考虑到激光在水与空气界面上的折射效应,利用斯涅尔定律计算角度。文章提供了一个C++实现的示例,展示了如何根据潜艇深度、飞机高度及距离等参数,精确计算激光发射的仰角。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

B - Refract Facts

A submarine is using a communications laser to send a message to a jet cruising overhead. The sea surface is flat. The submarine is cruising at a depth d below the surface. The jet is at height h above the sea surface, and a horizontal distance x from the sub. The submarine turns toward the jet before starting communications, but needs to know the angle of elevation, φ, at which to aim the laser.

refract.png

When the laser passes from the sea into the air, it is refracted (its path is bent). The refraction is described by Snell's law, which says that light approaching the horizontal surface at an angle θ1, measured from the vertical, will leave at an angle θ2, given by the formula

sin θ1 / sin θ2 = n1 / n2

where n1 and n2 are the respective refraction indices of the water and air. (The refraction index of a material is inversely proportional to how fast light can travel through that material.)

snell.png

Input

Each test case consists of a single line of input containing 5 space-separated floating point numbers:

  • d, the depth of the submarine (specifically, of the laser emitter) in feet, 1 <= d <= 800
  • h, the height of the plane in feet, 100 <= h <= 10,000
  • x, the horizontal distance from the sub to the plane in feet, 0 <= x <= 10,000
  • n1, the refractive index of water, 1.0 < n1 <= 2.5
  • n2, the refractive index of air, 1.0 <= n2 < n1

Input ends with a line containing 5 zeroes (0 0 0 0 0).

Output

For each test case, print a single line containing the angle of elevation φ at which the submarine should aim its laser to illuminate the jet.

The angle should be displayed in degrees and rounded to the closest 1/100 of a degree. Exactly two digits after the decimal point should be displayed.

Sample Input

600 600 1000 1.333 1.01
600 1200 4000 1.5 1.01
400 100 10000 2.5 1.01
0 0 0 0 0

Sample Output

44.37
11.51
2.30

这道题就是要二分求值,对θ1的角度进行二分,范围在0-90度,所求的角度φ为90-θ1,可以得到公式h*tan(θ2)+d*tan(θ1)=x,

关键是求出θ1和θ2的值。asin(sinθ2)=θ2的角度。如asin(sinπ/2)=45° .

#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI acos(-1.0)
#define eps 1e-6
using namespace std;

int main()
{
    double d,h,x,n1,n2;
    while(~scanf("%lf %lf %lf %lf %lf",&d,&h,&x,&n1,&n2))
    {
        if(d==0&&h==0&&d==x&&h==n1&&n2==0)
            break;
        double l=0,r=90,ang1,ang2,mid;
        while(l+eps<=r)
        {
            mid=(l+r)/2;
            ang1=mid/180*PI;
            ang2=asin(sin(ang1)*n2/n1);
            if(h*tan(ang2)+d*tan(ang1)<=x)
                l=mid;
            else
                r=mid;
        }
        printf("%.2lf\n",90-r);
    }
    return 0;
}

 

在机器人操作系统(ROS)中,机器视觉是机器人感知和理解周围环境的关键技术。robot_vision功能包专注于这一领域,集成了多种视觉处理技术,包括摄像头标定、OpenCV库应用、人脸识别、物体跟踪、二维码识别和物体识别,极大地拓展了ROS在视觉应用方面的能力。 摄像头标定:作为机器视觉的基础,摄像头标定用于消除镜头畸变并获取相机的内参和外参。在ROS中,camera_calibration包提供了友好的用户界面和算法,帮助计算相机参数矩阵,为后续的图像校正和三维重建提供支持。 OpenCV:OpenCV是一个广泛使用的开源计算机视觉库,在ROS中扮演着重要角色。robot_vision功能包可能包含OpenCV的示例代码和节点,涵盖图像处理、特征检测、模板匹配和图像分割等功能,这些功能对机器人视觉系统至关重要。 人脸识别:ROS中的人脸识别结合了图像处理和机器学习技术。robot_vision可能集成了基于OpenCV的人脸检测算法,如Haar级联分类器或Adaboost方法,甚至可能包含深度学习模型(如FaceNet或SSD),帮助机器人实现人脸的识别和跟踪,提升人机交互能力。 物体跟踪:物体跟踪使机器人能够持续关注并追踪特定目标。在ROS中,通常通过卡尔曼滤波器、粒子滤波器或光流法实现。robot_vision功能包可能包含这些算法的实现,助力机器人完成动态目标跟踪任务。 二维码识别:二维码是一种高效的信息编码方式,常用于机器人定位和导航。ROS中的二维码包可用于读取和解析二维码,而robot_vision可能进一步封装了这一功能,使其更易于集成到机器人系统中。 物体识别:作为机器视觉的高级应用,物体识别通常涉及深度学习模型,如YOLO、SSD或Faster R-CNN。robot_vision功能包可能包含预训练的模型和对应的ROS节点,使机器人能够识别环境中的特
内容概要:文章探讨了人们对人工智能(AI)的恐惧根源,指出尽管科技大佬们不断强调AI的好处,但大众仍对其存在广泛担忧。主要恐惧集中在AI可能引发的大规模失业、超越人类控制、以及对人类尊严和幸福感的剥夺等方面。文章还提到AI发展速度快于人类学习进步速度,可能导致部分工作岗位消失且不再创造大量低技术性岗位。此外,AI的自我学习与进化能力、数据隐私问题、权力集中趋势以及缺乏人类价值观和道德标准也加剧了人们的不安。最后,文章呼吁个人应正视这一趋势并学会利用AI技术,同时在宏观层面上加强AI的安全管控和伦理设计,以减少潜在风险。 适合人群:对人工智能发展及其社会影响感兴趣的读者,包括科技爱好者、政策制定者、企业管理者及普通民众。 使用场景及目标:①帮助读者理解当前社会对AI的普遍担忧及其背后原因;②为相关领域的从业者提供思考方向,如如何应对AI带来的职业挑战;③为政策制定者提供参考,以便更好地规划AI治理框架。 阅读建议:本文深入剖析了AI带来的多方面影响,建议读者结合自身背景和行业特点进行思考,尤其是关注AI对未来就业市场和社会结构的潜在改变。同时,考虑到文章涉及较多技术和社会学概念,建议读者在阅读过程中查阅相关资料,以便更全面地理解文中观点。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值