[sicily online]1070. Hansel and Grethel

通过测量两个地标的方向并结合地图坐标,本算法能够精确计算出人物的当前位置。涉及到坐标转换及直线交点计算。

Constraints

Time Limit: 1 secs, Memory Limit: 32 MB

Description

On a warm summer afternoon, Hansel and Grethel are walking together in the fields. It is getting late and, to be honest, they are lost. Grethel is a little scared, still vividly remembering the last time they got lost in the forest. That time, an evil witch had locked them inside a house built of gingerbread and sugar! But Hansel can reassure her: this time they are well prepared. Hansel has taken a map and a compass with him!

Hansel picks two clearly outstanding features in the landscape, and uses the compass to measure the direction towards both objects. Grethel locates the objects on the map, and writes down the corresponding map coordinates. Based on this information, they will be able to accurately determine their own position on the map.



The coordinates of two marker objects, and the direction (angle from the North) towards these objects are known. Write a program which uses this data to calculate the coordinates of Hansel and Grethel's current location.

Input

The first line of the input contains one positive number: the number of situations in which a position must be determined. Following are two lines per situation, describing the two marker objects. Each marker object is described by a line containing three integer numbers:

> the x-coordinate of the object on the map (0 <= x <= 100);

the x-axis runs West-to-East on the map, with increasing values towards the East.

> the y-coordinate of the object on the map (0 <= y <= 100);

the y-axis runs South-to-North on the map, with increasing values towards the North.

> the direction d of the object in degrees (0 <= d < 360);

with 0 = North, 90 = East, 180 = South, and so on.

To keep the position calculations accurate, Hansel makes sure that the directions of the two objects are not exactly equal, and do not differ by exactly 180.

Output

One line per situation, containing the result of the position calculation: two numbers, separated by a space, each having exactly 4 digits after the decimal point. These numbers represent the x and y coordinates of the position of Hansel and Grethel (0 <= x, y <= 100). Round the numbers as usual: up if the next digit would be >= 5, down otherwise.

Sample Input

2 
30 50 90 
20 40 180 
30 40 96 
20 20 150

Sample Output

20.0000 50.0000 
7.0610 42.4110

题目分析:

其实就是求两个之间的交点,有两个需要注意的地方

1,直线斜率不存在的时候

2,人的角度到坐标系的斜率的转化

#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<cmath>
#include<iomanip>
#include<list>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
#include <stack>
#include<queue>
#include<string.h>
#include<set>
using namespace std;

const double PI=3.14159265;
const int MAX=999999;

int main()
{
	//cout<<tan(PI);
	int n;
	cin>>n;
	for(int xx=0;xx<n;xx++)
	{
		int x1,y1,r1;
		int x2,y2,r2;
		cin>>x1>>y1>>r1>>x2>>y2>>r2;
		if(r1>=180)
			r1=r1-180;
		if(r2>=180)
			r2=r2-180;
		r1=90-r1;
		r2=90-r2;
		double k1,b1,k2,b2;
		double x,y;
		if(fabs((double)r1)!=90.0)
		{
			k1=tan(r1/180.0*PI);
			b1=y1-x1*k1;
		}
		if(fabs((double)r2)!=90.0)
		{
			k2=tan(r2/180.0*PI);
			b2=y2-x2*k2;
		}
		if(fabs((double)r1)==90.0)
		{
			x=x1;
			y=k2*x+b2;
		}
		else if(fabs((double)r2)==90.0)
		{
			x=x2;
			y=k1*x+b1;
		}
		else 
		{
			x=(b2-b1)/(k1-k2);
			y=k1*x+b1;
		}
		cout<<setiosflags(ios::fixed)<<setprecision(4)<<fabs(x)<<" "<<fabs(y)<<endl;
	}
}



内容概要:本文围绕“基于交流潮流的电力系统多元件N-k故障模型研究”展开,深入探讨了利用Matlab代码实现电力系统在发生多个关键元件同时故障(即N-k故障)情况下的交流潮流计算与故障分析方法。该模型不仅考虑了传统潮流方程的非线性特性,还引入了故障约束条件,能够精确模拟复杂多样的故障场景,如短路、断线等,进而评估电网在极端运行条件下的稳态与动态行为。研究通过构建典型电力系统算例,验证了所提模型在故障筛选、脆弱性识别及系统恢复策略制定方面的有效性,为电力系统安全评估、风险预警和防御体系构建提供了坚实的理论依据和技术支撑。此外,模型具备良好的扩展性,可进一步应用于连锁故障传播分析、恶意攻击模拟等高级安全分析领域。; 适合人群:具备电力系统分析基础理论知识和Matlab编程能力的高校研究生、科研院所研究人员以及电力公司从事电网规划、运行与安全管理的技术人员,特别适用于开展电力系统安全稳定、可靠性评估与应急响应机制研究的专业人士。; 使用场景及目标:①开展电力系统在多重故障条件下的交流潮流仿真,评估系统电压稳定性、线路过载风险及负荷损失程度;②识别电网中的关键薄弱环节与脆弱元件,支撑电网加固改造与防御资源配置;③用于科研项目中的故障场景建模与算法验证,或作为教学案例帮助学生理解复杂故障下的系统响应机制。; 阅读建议:此资源以Matlab代码为核心实现手段,建议读者结合理论推导与代码实现进行对照学习,重点关注故障建模过程中雅可比矩阵的修正方法、故障注入方式及收敛性处理策略,建议在仿真中逐步增加故障数量与复杂度,深入理解N-k故障对系统潮流分布的影响规律,并尝试将其拓展至含新能源接入的现代电力系统场景中进行验证与优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值