Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
Draw1.cpp
Package: 基本GIS系统开发.rar [view]
Upload User: yklx818
Upload Date: 2013-04-13
Package Size: 459k
Code Size: 3k
Category:
GIS program
Development Platform:
Visual C++
- // Draw1.cpp: implementation of the CDraw class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Draw.h"
- #include "Draw1.h"
- #include "math.h"
- #define pi 3.1415926
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- //CDraw::CDraw();
- float GetAngle(float xx,float yy,float m_x,float m_y);
- float GetAngle(float xx,float yy,float m_x,float m_y)
- {
- float i;
- i=(float)acos((m_x-xx)/sqrt((m_y-yy)*(m_y-yy)+(m_x-xx)*(m_x-xx)));
- return i;
- }
- float CDraw::PointLine(float xx,float yy,float x1,float y1,float x2,float y2)
- {
- float a,b,c,ang1,ang2,ang;
- a=CalDisp(x1,y1,xx,yy);
- if(a==0.0)
- return 0.0;
- b=CalDisp(x2,y2,xx,yy);
- if(b==0.0)
- return 0.0;
- c=CalDisp(x1,y1,x2,y2);
- if(c==0.0)
- return a;
- if(a<b)
- {
- if(fabs(y1-y2)<=0.001)
- {
- if(x1<x2)
- ang1=0;
- else
- ang1=(float)pi;
- }
- else
- {
- ang1=(float)acos((x2-x1)/c);
- if(y1>y2)
- ang1=(float)pi*2-ang1;
- }
- ang2=(float)acos((xx-x1)/a);
- if(y1>yy)
- ang2=(float)pi*2-ang2;
- ang=ang2-ang1;
- if(ang<0)
- ang=-ang;
- if(ang>pi)
- ang=(float)pi*2-ang;
- if(ang>pi/2)
- return a;
- else
- return (a*(float)sin(ang));
- }
- else
- {
- if(fabs(y1-y2)<=0.001)
- {
- if(x1<x2)
- ang1=(float)pi;
- else
- ang1=0;
- }
- else
- {
- ang1=(float)acos((x1-x2)/c);
- if(y2>y1)
- ang1=(float)pi*2-ang1;
- }
- ang2=(float)acos((xx-x2)/b);
- if(y2>yy)
- ang2=(float)pi*2-ang2;
- ang=ang2-ang1;
- if(ang<0)
- ang=-ang;
- if(ang>pi)
- ang=(float)pi*2-ang;
- if(ang>pi/2)
- return b;
- else
- return(b*(float)sin(ang));
- }
- }
- float CDraw::CalDisp(float x1,float y1,float x2,float y2)
- {
- return (float)sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
- }
- void CDraw::CalArea()
- {
- }
- void CDraw::CalLong()
- {
- }
- BOOL CDraw::PointRgn(float x,float y,int Numble,PointStruct* PointList,float blc)
- {
- CRgn rgn;
- int x1,y1,i;
- POINT* pPoint;
- if(Numble<3)
- return 0;
- pPoint=new POINT[Numble];
- x1=(int)(x/blc);
- y1=(int)(y/blc);
- for(i=0;i<Numble;i++)
- {
- pPoint[i].x=(int)((PointList[i].x)/blc);
- pPoint[i].y=(int)((PointList[i].y)/blc);
- }
- rgn.CreatePolygonRgn(pPoint,Numble,0);
- i=(rgn.PtInRegion(x1,y1)!=0);
- rgn.DeleteObject();
- return i;
- }
- void CDraw::RotatePoint(float baseX,float baseY,float angle,float *xx,float *yy)
- {
- float xx1,yy1;
- xx1=*xx;
- yy1=*yy;
- double angle1=GetAngle(baseX,baseY,xx1,yy1);
- double j1=CalDisp(baseX,baseY,xx1,yy1);
- xx1=baseX+j1*cos(angle+angle1);
- yy1=baseY+j1*sin(angle+angle1);
- *xx=xx1;
- *yy=yy1;
- }
- float CDraw::GetAngle(float baseX,float baseY,float xx,float yy)
- {
- float r,ang;
- // 如果基点和计算点是同一个点
- if(fabs(baseX-xx)<=0.001&&fabs(baseY-yy)<=0.001)
- return 0;
- if(fabs(baseX-xx)<=0.001)
- {
- if(yy>baseY)
- ang=(float)(pi/2);
- else
- ang=(float)(pi*3/2);
- return ang;
- }
- else
- {
- r=(float)sqrt((xx-baseX)*(xx-baseX)+(yy-baseY)*(yy-baseY));
- double kk=(xx-baseX)/r;
- ang=(float)acos(kk);
- if(yy<baseY)
- ang=(float)(pi*2)-ang;
- return ang;
- }
- }
- void CDraw::Delete(BOOL bDelete)
- {
- b_Delete=bDelete;
- }
- BOOL CDraw::IsFill()
- {
- return FALSE;
- }
- CDraw::~CDraw()
- {
- }