http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3608

Signal Detection


Time Limit: 2 Seconds      Memory Limit: 65536 KB

Parallelepiped
Type Prism
Faces 6 parallelograms
Edges 12
Vertices 8

Dr. Gale is testing his laser system. He uses a detector to collect the signals from a laser generator. He also puts a special prism in the system so that he can filter the noise. But he is not very sure where to put the detector to collect the signals. Can you help him with this problem?


In order to simplify the problem, here we assume the prism is a parallelepiped, which is a three-dimensional figure formed by six parallelograms. The laser goes in one direction and the detector can receive signals from any direction. The detector is placed on the ground where the z-coordinate is zero. There is no energy lost in the refraction. That is to say, there is no reflection in the signal transmission. You don't need to consider the situation of total reflection or the degenerate situation.

Input

There are multiple test cases. The first line of input contains an integer T (T ≤ 50) indicating the number of test cases. Then T test cases follow.

The first line of each test case contains 3 integers, indicating the coordinates of the laser generator. The second line contains 3 integers describing a point the laser will go through without the prism. The third line contains 3 integers describing a vertex A of the prism. The fourth to the sixth lines contain 3 integers each, describing an adjacent vertex of A. The seventh line contains a real number u, the refractive index of the prism.(1 < u ≤ 10) The absolute value of the coordinates will not exceed 1000. The z coordinates are all nonnegative. The prism and the laser generator are strictly above the ground and the laser generator will not be inside the prism.

Output

If there is no place in the ground that can receive the signals output "Error". Otherwise, output the x and y coordinates the place accurate to 0.001.

Sample Input

2
0 0 10
0 0 0
-5 -5 1
5 -5 11
-5 5 1
-6 -5 2
1.4142136
0 0 10
0 0 11
-5 -5 1
5 -5 1
-5 5 1
-5 -5 2
2

Sample Output

0.423 0.000
Error

References


Author: GUAN, Yao
Contest: The 9th Zhejiang Provincial Collegiate Programming Contest

AC代码:

 #include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <time.h>
using namespace std;
typedef long long llong; inline int bit(int x, int i){ return (x>>i) & ;}
inline int setb(int x, int i){ return x | ( << i);}
inline int clrb(int x, int i){ return x & (~( << i));}
inline int lowb(int x){return x & (-x);}
const double eps = 1e-;
struct Point{
double x, y, z;
Point(){}
Point(double x, double y, double z):x(x), y(y), z(z){}
double len(){
return sqrt(x * x + y * y + z * z);
}
Point shrink(double l = 1.0){
double s = l / len();
return Point(x * s, y * s, z * s);
}
void input(){
scanf("%lf %lf %lf", &x, &y, &z);
}
}; Point operator +(const Point &p, const Point &q){
return Point(p.x + q.x, p.y + q.y, p.z + q.z);
}
Point operator -(const Point &p, const Point &q){
return Point(p.x - q.x, p.y - q.y, p.z - q.z);
}
Point operator *(const Point &p, const double &s){
return Point(p.x * s, p.y * s, p.z * s);
}
Point operator *(const Point &p, const Point &q){
return Point(p.y * q.z - p.z * q.y,
p.z * q.x - p.x * q.z,
p.x * q.y - p.y * q.x);
}
double operator &(const Point &p, const Point &q){
return p.x * q.x + p.y * q.y + p.z * q.z;
} Point p, q, v[];
double r;
int face[][] ={
{, , , },
{, , , },
{, , , },
{, , , },
{, , , },
{, , , },
};
Point fn[];
double fb[]; double inter(const Point &p, const Point &d, const Point &n, double b){
return (b - (n & p)) / (n & d);
}
bool collide(double R){
int hf = -;
double ht;
Point d = (q - p);
for(int i = ;i < ; ++i){
if(fabs(fn[i] & d) < eps) continue;
double t = inter(p, d, fn[i], fb[i]);
if(t <= eps) continue;
Point hit = p + d * t;
bool ok = true;
for(int j = ;j < ; ++j){
if((((v[face[i][j]]-hit) * (v[face[i][(j + )%]] - hit)) & fn[i]) <= ) ok = false;
}
if(ok && (hf < || t < ht)){
hf = i;
ht = t;
}
}
if(hf < ) return false; Point hit = p + d * ht;
Point vx = fn[hf].shrink();
if(fabs((vx * d).len()) < eps){
p = hit;
q = hit + d;
return true;
}
double dx = vx & d;
if(dx < ) vx = vx * -, dx = -dx;
Point vy = ((vx * d) * vx).shrink();
double dy = vy & d;
if(dy < ) vy = vy * -, dy = -dy;
double theta0 = atan2(dy, dx);
double theta = asin(sin(theta0) / R);
d = vx * cos(theta) + vy * sin(theta);
p = hit;
q = hit + d;
return true;
}
int main(){
int TT;
scanf("%d", &TT);
for(int cas = ; cas <= TT; ++cas){
p.input();
q.input(); v[].input();
v[].input();
v[].input();
v[] = v[] + v[] - v[]; v[].input();
v[] = v[] + v[] - v[];
v[] = v[] + v[] - v[];
v[] = v[] + v[] - v[]; scanf("%lf", &r);
for(int i = ;i < ; ++i){
fn[i] = (v[face[i][]] - v[face[i][]]) *
(v[face[i][]] - v[face[i][]]);
fb[i] = fn[i] & v[face[i][]];
}
if(collide(r)){
collide(./r);
}
Point norm(, , );
Point dir = q - p;
if(fabs(norm & dir) < eps) puts("Error");
else{
double t = inter(p, dir, norm, );
if(t < ) puts("Error");
else{
Point hit = p + dir * t;
printf("%.3f %.3f\n", hit.x, hit.y);
}
}
}
return ;
}

zjuoj 3608 Signal Detection的更多相关文章

  1. 第二届普适计算和信号处理及应用国际会议论文2016年 The 2nd Conference on Pervasive Computing, Signal Processing and Applications(PCSPA, 2016)

    A New Method for Mutual Coupling Correction of Array Output Signal 一种阵列输出信号互耦校正的新方法 Research of Robu ...

  2. Image Processing and Analysis_8_Edge Detection:Statistical edge detection_ learning and evaluating edge cues——2003

    此主要讨论图像处理与分析.虽然计算机视觉部分的有些内容比如特 征提取等也可以归结到图像分析中来,但鉴于它们与计算机视觉的紧密联系,以 及它们的出处,没有把它们纳入到图像处理与分析中来.同样,这里面也有 ...

  3. libevent

    libevent doc example #include <event2/event.h> void cb_func(evutil_socket_t fd, short what, vo ...

  4. ROC和AUC介绍以及如何计算AUC ---好!!!!

    from:https://www.douban.com/note/284051363/?type=like 原帖发表在我的博客:http://alexkong.net/2013/06/introduc ...

  5. 【转】ROC和AUC介绍以及如何计算AUC

    转自:https://www.douban.com/note/284051363/ ROC(Receiver Operating Characteristic)曲线和AUC常被用来评价一个二值分类器( ...

  6. 利用过采样技术提高ADC测量微弱信号时的分辨率

    1. 引言 随着科学技术的发展,人们对宏观和微观世界逐步了解,越来越多领域(物理学.化学.天文学.军事雷达.地震学.生物医学等)的微弱信号需要被检测,例如:弱磁.弱光.微震动.小位移.心电.脑电等[1 ...

  7. DSP开发资源总结,经典书籍,论坛

    OMAP4开发资源总结: 一.TI OMAP4官网介绍: http://www.ti.com.cn/general/cn/docs/wtbu/wtbuproductcontent.tsp?templa ...

  8. 分类器的评价指标-ROC&AUC

    ROC 曲线:接收者操作特征曲线(receiver operating characteristic curve),是反映敏感性和特异性连续变量的综合指标,roc 曲线上每个点反映着对同一信号刺激的感 ...

  9. 2012-2014 三年浙江 acm 省赛 题目 分类

    The 9th Zhejiang Provincial Collegiate Programming Contest A    Taxi Fare    25.57% (166/649)     (水 ...

随机推荐

  1. java画图程序_图片用字母画出来_源码发布

    在之前写了一篇blog:java画图程序_图片用字母画出来 主要是把一些调试的截图发布出来,现在程序调试我认为可以了(当然,你如果还想调试的话,也可以下载源码自己调试). 就把源码发布出来. 项目结构 ...

  2. spring源码学习之路---AOP初探(六)

    作者:zuoxiaolong8810(左潇龙),转载请注明出处,特别说明:本博文来自博主原博客,为保证新博客中博文的完整性,特复制到此留存,如需转载请注明新博客地址即可. 最近工作很忙,但当初打算学习 ...

  3. JavaScript_JS判断客户端是否是iOS或者Android

    通过判断浏览器的userAgent,用正则来判断是否是ios和Android客户端.代码如下: <script type="text/javascript"> var ...

  4. 使用forever管理nodejs应用

    1. forever介绍 forever是一个简单的命令式nodejs的守护进程,能够启动,停止,重启App应用.forever完全基于命令行操作,在forever进程之下,创建node的子进程,通过 ...

  5. java工程展示问题

    当java工程这样展示时,需要选择window---->Open Perspective----->java改变java工程的展示方式

  6. Load Mental Ray in Maya 2015

    In Maya 2015, we usually use mental ray to render our model, some new users may not see the mental r ...

  7. spring security 图解过滤器的使用

    1. HttpSessionContextIntegrationFilter 位于过滤器顶端,第一个起作用的过滤器. 用途一,在执行其他过滤器之前,率先判断用户的session中是否已经存在一个Sec ...

  8. spidermark sensepostdata ntp_monlist.py

    试NTP 时间服务器用的,ntp_ip_enum.py,源码如下:#!/usr/bin/env python"""Basic script to pull address ...

  9. Python使用split使用多个字符分隔字符串

    Python的str类有split方法,但是这个split方法只能根据指定的某个字符分隔字符串,如果要同时指定多个字符来分隔字符串,该怎么办呢? 幸运的是python的re模块中提供的split方法可 ...

  10. ThinkPHP 3.2.3 简单后台模块开发(二)RBAC

    RBAC(Role-Based Access Controll)基于角色的访问控制 在 ThinkPHP3.2.3 中 RBAC 类位于 /ThinkPHP/Library/Org/Util/Rbac ...