惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
P
Privacy International News Feed
L
LINUX DO - 热门话题
T
Threatpost
Latest news
Latest news
C
Cybersecurity and Infrastructure Security Agency CISA
Cisco Talos Blog
Cisco Talos Blog
Cyberwarzone
Cyberwarzone
Spread Privacy
Spread Privacy
Recent Announcements
Recent Announcements
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
NISL@THU
NISL@THU
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
K
Kaspersky official blog
L
Lohrmann on Cybersecurity
V
Vulnerabilities – Threatpost
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
Y
Y Combinator Blog
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
H
Help Net Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cisco Blogs
Security Latest
Security Latest
博客园 - 叶小钗
博客园 - Franky
The Hacker News
The Hacker News
Engineering at Meta
Engineering at Meta
Scott Helme
Scott Helme
S
Securelist
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
博客园 - 【当耐特】
A
About on SuperTechFans
C
Cyber Attacks, Cyber Crime and Cyber Security
博客园_首页
B
Blog RSS Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
月光博客
月光博客
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Tor Project blog
A
Arctic Wolf

博客园 - RayG

How to get data from Oracle DB in silverlight via WCF ? [Ray]How to use CString to create a font family - RayG [Copied] 80 VC++ tips [Copied]The GDI Coordinate Systems My Cheating Death solution in VC++ trouble shoot about using BindLayer in MapX with C# [原创] 计算几何常用算法(转) Trouble shooting about installation of ArcSDE 9.2 File type transform between ArcGIS and other major type - RayG [Tips] How to converting a Coverage to a Shapefile ? - RayG [Tips] How to Add New field into Shapefile attribute table in ArcGIS ? 子非鱼,安知鱼之乐? [GuanRui] My program implement on Symbian S60 (#1: File IO) - RayG My XNA HitBee small game [GuanRui]How to open Path browse dialog in VBA of ArcGIS Desktop ? [Ray] My GPS (卫星定位接收器) tracker program on Symbian OS Binary Tree ANSI C Implement (2) - RayG Binary Tree ANSI C Implement (1) Graph & Topology & Shortest path
3 given points, get the angle between two lines
RayG · 2009-04-15 · via 博客园 - RayG

该函数包含三个点的位置参数,

点A(x1,y1)    点B(x2,y2)  点C(x3,y3)  

从A点到B点连线成边L1,从C点到B点连线成边L2。 公式CountAngle返回的结果就是从L1顺时针转到L2的夹角度数,以DOUBLE类型返回。 

double CMapRender::CountAngle(double x1, double y1, double x2, double y2, double x3, double y3)

{   

if(0 == ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) )

return -1;

double sin1 = (y1 - y2) / sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));//第一个坐标点和第二个坐标所在直线与X坐标正半轴逆时针所成角的正弦值

double cos1 = (x1 - x2) / sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));//第一个坐标点和第二个坐标所在直线与X坐标正半轴逆时针所成角的余弦值

double sin2 = (y3 - y2) / sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));//第三个坐标点和第二个坐标所在直线与X坐标正半轴逆时针所成角的正弦值

double cos2 = (x3 - x2) / sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));//第三个坐标点和第二个坐标所在直线与X坐标正半轴逆时针所成角的余弦值

double angle11 = (double)asin(sin1);//第一个坐标点和第二个坐标所在直线与X坐标正半轴逆时针所成角正弦值的反正弦值

double angle22 = (double)asin(sin2);//第三个坐标点和第二个坐标所在直线与X坐标正半轴逆时针所成角正弦值的反正弦值

double angle1,angle2;

double angle;

double PI = 3.1415926 ;

//第一个坐标点和第二个坐标所在直线与X坐标正半轴逆时针所成角

if(sin1 >= 0 && cos1 >= 0)

angle1 = angle11;

else

{

if(sin1 >= 0 && cos1 < 0)

angle1 = PI - angle11;

else

if(sin1 < 0 && cos1 <= 0)

angle1 = PI - angle11;

else

angle1 = 2 * PI + angle11;

}

//第三个坐标点和第二个坐标所在直线与X坐标正半轴逆时针所成角

if(sin2 >= 0 && cos2 >= 0)

angle2 = angle22;

else

{

if(sin2 >= 0 && cos2 < 0)

angle2 = PI - angle22;

else

if(sin2 < 0 && cos2 <= 0)

angle2 = PI - angle22;

else

angle2 = 2 * PI + angle22;

}

//第一个坐标点和第二个坐标所在直线到第三个坐标点和第二个坐标所在直线的顺时针的角

if(angle1 >= angle2)

angle = (180 / PI) * (angle1 - angle2);

else

angle = 360 - (180 / PI) * (angle2 - angle1);

return angle;

}