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. BZOJ4027: [HEOI2015]兔子与樱花 贪心

    觉得是贪心,但是一开始不太肯定...然后就A了 一个点对它的父亲的贡献就是自己的权值加儿子的个数 #include<bits/stdc++.h> using namespace std; ...

  2. SDL 五子棋游戏

    http://www.jb51.net/article/79271.htm 1.定义窗口大小,棋盘大小 SDL_GetWindowSize()读取窗口大小, 由于棋盘是15*15格局,上下留白一行,在 ...

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

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

  4. flex的http URL转码与解码

    private function httpEncoding(param:String):String{    //转码     return encodeURIComponent(param); } ...

  5. (转)教你实现Winform窗体的四边阴影效果

    1.首先我们得有这样一张阴影图片. 2.然后分别有两个窗体去实现这个阴影效果. SkinForm - 用于实现阴影的绘制,特性:鼠标可穿透,无法点击,跟随窗体. SkinMain - 主窗体,也是承载 ...

  6. 使用JDK自带的visualvm进行性能监测和调优

    使用JDK自带的visualvm进行性能监测和调优   1.关于VisualVm工具  VisualVM 提供在 Java 虚拟机 (Java Virutal Machine, JVM) 上运行的 J ...

  7. JAVA给图片加上水印

    import java.awt.Color;       import java.awt.Font;       import java.awt.Graphics;       import java ...

  8. The Bus Driver Problem

    题目连接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=90648#problem/G 题意: 给每位司机分配一个白天和晚上的行车路线, ...

  9. 从show slave status 中判断mysql同步状态

    slave status 中检查同步状态: 1.sql线程和io线程显示yes Slave_IO_Running: Yes Slave_SQL_Running: Yes 2. Master_Log_F ...

  10. HDU1134/HDU1133 递推 大数 java

    Game of Connections Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...