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
MirrorShape.cpp
Package: CAD.zip [view]
Upload User: hehe2haha
Upload Date: 2013-08-16
Package Size: 161k
Code Size: 2k
Category:
CAD
Development Platform:
Visual C++
- // MirrorShape.cpp: implementation of the MirrorShape class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "MirrorShape.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CMirrorShape::CMirrorShape()
- {
- SinAngle = 0;
- CosAngle = 0;
- TgAngle = 0;
- }
- CMirrorShape::~CMirrorShape()
- {
- }
- void CMirrorShape::SetSinCos(POINT BeginPos, POINT EndPos)
- {
- int Length = CDraw::Distance(BeginPos,EndPos);
- if (Length != 0)
- {
- //求参考线与X轴夹角的正弦、余弦
- SinAngle = (double)(EndPos.y - BeginPos.y) / Length;
- CosAngle = (double)(EndPos.x - BeginPos.x) / Length;
- //参考线与Y轴平行
- if (EndPos.x == BeginPos.x && EndPos.y != BeginPos.y);
- else
- {
- //求参考线与X轴夹角的正切
- TgAngle = (double)(EndPos.y - BeginPos.y) / (EndPos.x - BeginPos.x);
- }
- }
- }
- void CMirrorShape::SetMirrorPos(POINT BeginPos, POINT EndPos)
- {
- double Length = 0.0;
- double xOffset = 0.0;
- double yOffset = 0.0;
- MirrorBeginPos = SourceBeginPos;
- MirrorEndPos = SourceEndPos;
- //参考线与Y轴平行
- if (EndPos.x == BeginPos.x && EndPos.y != BeginPos.y)
- {
- xOffset = (double)2 * (BeginPos.x - SourceBeginPos.x);
- MirrorBeginPos.x += (long)xOffset;
- xOffset = (double)2 * (BeginPos.x - SourceEndPos.x);
- MirrorEndPos.x += (long)xOffset;
- }
- else
- {
- Length = BeginPos.y + TgAngle * (SourceBeginPos.x - BeginPos.x);
- Length = SourceBeginPos.y - Length;
- Length = Length * CosAngle;
- xOffset = 2 * Length * SinAngle;
- yOffset = 2 * Length * CosAngle;
- MirrorBeginPos.x += (long)xOffset;
- MirrorBeginPos.y -= (long)yOffset;
- Length = BeginPos.y + TgAngle * (SourceEndPos.x - BeginPos.x);
- Length = SourceEndPos.y - Length;
- Length = Length * CosAngle;
- xOffset = 2 * Length * SinAngle;
- yOffset = 2 * Length * CosAngle;
- MirrorEndPos.x += (long)xOffset;
- MirrorEndPos.y -= (long)yOffset;
- }
- }