📄 010763view.cpp
字号:
// 010763View.cpp : implementation of the CMy010763View class
//
#include "stdafx.h"
#include "010763.h"
#include "010763Doc.h"
#include "010763View.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMy010763View
IMPLEMENT_DYNCREATE(CMy010763View, CView)
BEGIN_MESSAGE_MAP(CMy010763View, CView)
//{{AFX_MSG_MAP(CMy010763View)
ON_COMMAND(ID_zhengset, Onzhengset)
ON_COMMAND(ID_toushiset, Ontoushiset)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMy010763View construction/destruction
CMy010763View::CMy010763View()
{
MessageBox("在左上角选择设置");
// TODO: add construction code here
}
CMy010763View::~CMy010763View()
{MessageBox("Thank you!!");
}
BOOL CMy010763View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMy010763View drawing
void CMy010763View::OnDraw(CDC* pDC)
{
CMy010763Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
double u,v,xx,yy,zz;
Pi = 3.1415926;
// TODO: add draw code for native data here
CClientDC dc(this);
/////// 1
for(x = -xwide;x <= xwide; x += dense) {
for(y = -ywide; y <= ywide; y++)
if(((e * e - 1) * x * x + 2 * c * x + (e * e - 1) * y * y - c * c) >= 0) {
z = sqrt((e * e - 1) * x * x + 2 * c * x + (e * e - 1) * y * y - c * c);
v = sqrt(bb * bb + cc * cc);
u = sqrt(aa * aa + bb * bb + cc * cc);
xx = (x+tx)*s*(aa*aa/(u*u) + v*v*cos(Pi*angle3)/(u*u))
+ (y+ty)*s * (aa*bb/(u*u) + v/u*(-aa*bb*cos(Pi*angle3)/(u*v)-cc*sin(Pi*angle3)/v))
+ (z+tz)*s * (aa*cc/(u*u) + v/u*(-aa*cc*cos(Pi*angle3)/(u*v)+bb*sin(Pi*angle3)/v))
+ xa + aa/u * (-aa*xa/u + 1/u * (-bb*ya -cc * za))+v/u*((-v*xa/u-aa/u*
(-bb*ya/v-cc*za/v))*cos(Pi*angle3)-(-cc*ya/v+bb*za/v)*sin(Pi*angle3));
yy = (x+tx)*s*(bb/v*(aa*v-aa*v*cos(Pi*angle3))/(u*u)+cc/u*sin(Pi*angle3))
+(y+ty)*s*(cc/v*(cc/v*cos(Pi*angle3)-aa*bb*sin(Pi*angle3)/(u*v))+
bb/v*(bb*v/u*u - aa/u*(-aa*bb*cos(Pi*angle3)/(u*v)-cc/v*sin(Pi*angle3))))
+(z+tz)*s*(cc/v*(-bb/v*cos(Pi*angle3)-aa*cc*sin(Pi*angle3)/u/v)+
bb/v*(cc*v/u/u-aa/u*(-aa*cc*cos(Pi*angle3)/u/v+bb/v*sin(Pi*angle3))))
+ya + cc/v*((-cc*ya/v+bb*za/v)*cos(Pi*angle3)+
(-v*xa/u-aa/u*(-bb*ya/v-cc*za/v))*sin(Pi*angle3))+bb/v*(v/u*(-aa*aa/u+v/u
*(-bb*ya/v-cc*za/v))-aa/u*((-v*xa/u-aa/u*(bb*ya/v-cc*za/v))
*cos(Pi*angle3)-(-cc*ya/v+bb*za/v)*sin(Pi*angle3)));
zz = (x+tx)*s*(cc/v*(aa*v/(u*u)-aa*v*cos(Pi*angle3)/u/u)-bb/u*sin(Pi*angle3))
+(y+ty)*s*(-bb/v*(cc/v*cos(Pi*angle3)-aa*bb*sin(Pi*angle3)/u/v)+
cc/v*(bb*v/u/u-aa/u*(-aa*bb*cos(Pi*angle3)/u/v-cc*sin(Pi*angle3)/v)))
+(z+tz)*s*(-bb/v*(-bb/v*cos(Pi*angle3)-aa*cc*sin(Pi*angle3)/u/v)+
cc/v*(cc*v/u/u-aa/u*(-aa*cc*cos(Pi*angle3)/u/v+bb*sin(Pi*angle3)/v)))
+za - bb/v*((-cc*ya/v+bb*za/v)*cos(Pi*angle3)+
(-v*xa/u-aa/u*(-bb*ya/v-cc*za/v))*sin(Pi*angle3))+
cc/v*(v/u*(-aa*xa/u+v/u*(-bb*ya/v-cc*za/v))
-aa/u*((-v*xa/u-aa/u*(-bb*ya/v-cc*za/v))*cos(Pi*angle3)-
(-cc*ya/v+bb*za/v)*sin(Pi*angle3)));
if(flag == 0) { //toushi
a = xx/(zz/d+1);
b = yy/(zz/d+1);
dc.SetPixel(ox + int(a),oy + int(b),1);
//above z
}
else { //zheng
a = cos(Pi*angle1) * xx - sin(Pi*angle1) * zz;
b = - sin(Pi*angle1) * sin(Pi*angle2) * xx +
yy * cos(Pi*angle2) - cos(Pi*angle1) * sin(Pi*angle2) * zz;
dc.SetPixel(ox + int(a),
oy + int(b),1);//above z
}
}//if
}//for
/////// 2
for(x = -xwide;x <= xwide; x += dense){
for(y = -ywide; y <= ywide; y++)
if(((e * e - 1) * x * x + 2 * c * x + (e * e - 1) * y * y - c * c) >= 0) {
z = - sqrt((e * e - 1) * x * x + 2 * c * x + (e * e - 1) * y * y - c * c);
v = sqrt(bb * bb + cc * cc);
u = sqrt(aa * aa + bb * bb + cc * cc);
xx = (x+tx)*s*(aa*aa/(u*u) + v*v*cos(Pi*angle3)/(u*u))
+ (y+ty)*s * (aa*bb/(u*u) + v/u*(-aa*bb*cos(Pi*angle3)/(u*v)-cc*sin(Pi*angle3)/v))
+ (z+tz)*s * (aa*cc/(u*u) + v/u*(-aa*cc*cos(Pi*angle3)/(u*v)+bb*sin(Pi*angle3)/v))
+ xa + aa/u * (-aa*xa/u + 1/u * (-bb*ya -cc * za))+v/u*((-v*xa/u-aa/u*
(-bb*ya/v-cc*za/v))*cos(Pi*angle3)-(-cc*ya/v+bb*za/v)*sin(Pi*angle3));
yy = (x+tx)*s*(bb/v*(aa*v-aa*v*cos(Pi*angle3))/(u*u)+cc/u*sin(Pi*angle3))
+(y+ty)*s*(cc/v*(cc/v*cos(Pi*angle3)-aa*bb*sin(Pi*angle3)/(u*v))+
bb/v*(bb*v/u*u - aa/u*(-aa*bb*cos(Pi*angle3)/(u*v)-cc/v*sin(Pi*angle3))))
+(z+tz)*s*(cc/v*(-bb/v*cos(Pi*angle3)-aa*cc*sin(Pi*angle3)/u/v)+
bb/v*(cc*v/u/u-aa/u*(-aa*cc*cos(Pi*angle3)/u/v+bb/v*sin(Pi*angle3))))
+ya + cc/v*((-cc*ya/v+bb*za/v)*cos(Pi*angle3)+
(-v*xa/u-aa/u*(-bb*ya/v-cc*za/v))*sin(Pi*angle3))+bb/v*(v/u*(-aa*aa/u+v/u
*(-bb*ya/v-cc*za/v))-aa/u*((-v*xa/u-aa/u*(bb*ya/v-cc*za/v))
*cos(Pi*angle3)-(-cc*ya/v+bb*za/v)*sin(Pi*angle3)));
zz = (x+tx)*s*(cc/v*(aa*v/(u*u)-aa*v*cos(Pi*angle3)/u/u)-bb/u*sin(Pi*angle3))
+(y+ty)*s*(-bb/v*(cc/v*cos(Pi*angle3)-aa*bb*sin(Pi*angle3)/u/v)+
cc/v*(bb*v/u/u-aa/u*(-aa*bb*cos(Pi*angle3)/u/v-cc*sin(Pi*angle3)/v)))
+(z+tz)*s*(-bb/v*(-bb/v*cos(Pi*angle3)-aa*cc*sin(Pi*angle3)/u/v)+
cc/v*(cc*v/u/u-aa/u*(-aa*cc*cos(Pi*angle3)/u/v+bb*sin(Pi*angle3)/v)))
+za - bb/v*((-cc*ya/v+bb*za/v)*cos(Pi*angle3)+
(-v*xa/u-aa/u*(-bb*ya/v-cc*za/v))*sin(Pi*angle3))+
cc/v*(v/u*(-aa*xa/u+v/u*(-bb*ya/v-cc*za/v))
-aa/u*((-v*xa/u-aa/u*(-bb*ya/v-cc*za/v))*cos(Pi*angle3)-
(-cc*ya/v+bb*za/v)*sin(Pi*angle3)));
if(flag == 0) { //toushi
dc.SetPixel(ox + int(xx/((zz/d)+1)),
oy + int(yy/(zz/d+1)),1);
//below z
}
else { //zheng
dc.SetPixel(ox + int(cos(Pi*angle1) * xx - sin(Pi*angle1) * (zz)),
oy + int(- sin(Pi*angle1) * sin(Pi*angle2) * xx +
yy * (cos(Pi*angle2) ) - cos(Pi*angle1) * sin(Pi*angle2) * (zz)),1);
//below z
}
}//if
}//for
//x grid
/////// 3
for(y = -ywide;y <= ywide; y += dense) {
for(x = -xwide; x <= xwide; x++)
if(((e * e - 1) * x * x + 2 * c * x + (e * e - 1) * y * y - c * c) >= 0) {
z = sqrt((e * e - 1) * x * x + 2 * c * x + (e * e - 1) * y * y - c * c);
v = sqrt(bb * bb + cc * cc);
u = sqrt(aa * aa + bb * bb + cc * cc);
xx = (x+tx)*s*(aa*aa/(u*u) + v*v*cos(Pi*angle3)/(u*u))
+ (y+ty)*s * (aa*bb/(u*u) + v/u*(-aa*bb*cos(Pi*angle3)/(u*v)-cc*sin(Pi*angle3)/v))
+ (z+tz)*s * (aa*cc/(u*u) + v/u*(-aa*cc*cos(Pi*angle3)/(u*v)+bb*sin(Pi*angle3)/v))
+ xa + aa/u * (-aa*xa/u + 1/u * (-bb*ya -cc * za))+v/u*((-v*xa/u-aa/u*
(-bb*ya/v-cc*za/v))*cos(Pi*angle3)-(-cc*ya/v+bb*za/v)*sin(Pi*angle3));
yy = (x+tx)*s*(bb/v*(aa*v-aa*v*cos(Pi*angle3))/(u*u)+cc/u*sin(Pi*angle3))
+(y+ty)*s*(cc/v*(cc/v*cos(Pi*angle3)-aa*bb*sin(Pi*angle3)/(u*v))+
bb/v*(bb*v/u*u - aa/u*(-aa*bb*cos(Pi*angle3)/(u*v)-cc/v*sin(Pi*angle3))))
+(z+tz)*s*(cc/v*(-bb/v*cos(Pi*angle3)-aa*cc*sin(Pi*angle3)/u/v)+
bb/v*(cc*v/u/u-aa/u*(-aa*cc*cos(Pi*angle3)/u/v+bb/v*sin(Pi*angle3))))
+ya + cc/v*((-cc*ya/v+bb*za/v)*cos(Pi*angle3)+
(-v*xa/u-aa/u*(-bb*ya/v-cc*za/v))*sin(Pi*angle3))+bb/v*(v/u*(-aa*aa/u+v/u
*(-bb*ya/v-cc*za/v))-aa/u*((-v*xa/u-aa/u*(bb*ya/v-cc*za/v))
*cos(Pi*angle3)-(-cc*ya/v+bb*za/v)*sin(Pi*angle3)));
zz = (x+tx)*s*(cc/v*(aa*v/(u*u)-aa*v*cos(Pi*angle3)/u/u)-bb/u*sin(Pi*angle3))
+(y+ty)*s*(-bb/v*(cc/v*cos(Pi*angle3)-aa*bb*sin(Pi*angle3)/u/v)+
cc/v*(bb*v/u/u-aa/u*(-aa*bb*cos(Pi*angle3)/u/v-cc*sin(Pi*angle3)/v)))
+(z+tz)*s*(-bb/v*(-bb/v*cos(Pi*angle3)-aa*cc*sin(Pi*angle3)/u/v)+
cc/v*(cc*v/u/u-aa/u*(-aa*cc*cos(Pi*angle3)/u/v+bb*sin(Pi*angle3)/v)))
+za - bb/v*((-cc*ya/v+bb*za/v)*cos(Pi*angle3)+
(-v*xa/u-aa/u*(-bb*ya/v-cc*za/v))*sin(Pi*angle3))+
cc/v*(v/u*(-aa*xa/u+v/u*(-bb*ya/v-cc*za/v))
-aa/u*((-v*xa/u-aa/u*(-bb*ya/v-cc*za/v))*cos(Pi*angle3)-
(-cc*ya/v+bb*za/v)*sin(Pi*angle3)));
if(flag == 0) {
a = xx/(zz/d+1);
b = yy/(zz/d+1);
dc.SetPixel(ox + int(a),
oy + int(b),1);//above z
}
else {
a = cos(Pi*angle1) * xx - sin(Pi*angle1) * zz;
b = - sin(Pi*angle1) * sin(Pi*angle2) * xx +
yy * cos(Pi*angle2) - cos(Pi*angle1) * sin(Pi*angle2) * zz;
dc.SetPixel(ox + int(a),oy + int(b),1);//above z
}
}//if
}//for
/////// 4
for(y = -ywide;y <= ywide; y += dense) {
for(x = -xwide; x <= xwide; x++)
if(((e * e - 1) * x * x + 2 * c * x + (e * e - 1) * y * y - c * c) >= 0) {
z = - sqrt((e * e - 1) * x * x + 2 * c * x + (e * e - 1) * y * y - c * c);
v = sqrt(bb * bb + cc * cc);
u = sqrt(aa * aa + bb * bb + cc * cc);
xx = (x+tx)*s*(aa*aa/(u*u) + v*v*cos(Pi*angle3)/(u*u))
+ (y+ty)*s * (aa*bb/(u*u) + v/u*(-aa*bb*cos(Pi*angle3)/(u*v)-cc*sin(Pi*angle3)/v))
+ (z+tz)*s * (aa*cc/(u*u) + v/u*(-aa*cc*cos(Pi*angle3)/(u*v)+bb*sin(Pi*angle3)/v))
+ xa + aa/u * (-aa*xa/u + 1/u * (-bb*ya -cc * za))+v/u*((-v*xa/u-aa/u*
(-bb*ya/v-cc*za/v))*cos(Pi*angle3)-(-cc*ya/v+bb*za/v)*sin(Pi*angle3));
yy = (x+tx)*s*(bb/v*(aa*v-aa*v*cos(Pi*angle3))/(u*u)+cc/u*sin(Pi*angle3))
+(y+ty)*s*(cc/v*(cc/v*cos(Pi*angle3)-aa*bb*sin(Pi*angle3)/(u*v))+
bb/v*(bb*v/u*u - aa/u*(-aa*bb*cos(Pi*angle3)/(u*v)-cc/v*sin(Pi*angle3))))
+(z+tz)*s*(cc/v*(-bb/v*cos(Pi*angle3)-aa*cc*sin(Pi*angle3)/u/v)+
bb/v*(cc*v/u/u-aa/u*(-aa*cc*cos(Pi*angle3)/u/v+bb/v*sin(Pi*angle3))))
+ya + cc/v*((-cc*ya/v+bb*za/v)*cos(Pi*angle3)+
(-v*xa/u-aa/u*(-bb*ya/v-cc*za/v))*sin(Pi*angle3))+bb/v*(v/u*(-aa*aa/u+v/u
*(-bb*ya/v-cc*za/v))-aa/u*((-v*xa/u-aa/u*(bb*ya/v-cc*za/v))
*cos(Pi*angle3)-(-cc*ya/v+bb*za/v)*sin(Pi*angle3)));
zz = (x+tx)*s*(cc/v*(aa*v/(u*u)-aa*v*cos(Pi*angle3)/u/u)-bb/u*sin(Pi*angle3))
+(y+ty)*s*(-bb/v*(cc/v*cos(Pi*angle3)-aa*bb*sin(Pi*angle3)/u/v)+
cc/v*(bb*v/u/u-aa/u*(-aa*bb*cos(Pi*angle3)/u/v-cc*sin(Pi*angle3)/v)))
+(z+tz)*s*(-bb/v*(-bb/v*cos(Pi*angle3)-aa*cc*sin(Pi*angle3)/u/v)+
cc/v*(cc*v/u/u-aa/u*(-aa*cc*cos(Pi*angle3)/u/v+bb*sin(Pi*angle3)/v)))
+za - bb/v*((-cc*ya/v+bb*za/v)*cos(Pi*angle3)+
(-v*xa/u-aa/u*(-bb*ya/v-cc*za/v))*sin(Pi*angle3))+
cc/v*(v/u*(-aa*xa/u+v/u*(-bb*ya/v-cc*za/v))
-aa/u*((-v*xa/u-aa/u*(-bb*ya/v-cc*za/v))*cos(Pi*angle3)-
(-cc*ya/v+bb*za/v)*sin(Pi*angle3)));
if(flag == 0) {
dc.SetPixel(ox + int(xx/((zz/d)+1)),oy + int((yy)/(zz/d+1)),1);//below z
}
else {
dc.SetPixel(ox + cos(Pi*angle1) * xx - sin(Pi*angle1) * (zz),
oy + int(- sin(Pi*angle1) * sin(Pi*angle2) * xx +
yy * (cos(Pi*angle2) ) - cos(Pi*angle1) * sin(Pi*angle2) * (zz)),1);
//below z
}
}//if
}//for //y grid
////////////
if(flag == 1) {
dc.MoveTo(ox + int(cos(Pi*angle1) * 2 * xwide),
oy + int(- sin(Pi*angle1) * sin(Pi*angle2) * 2 * xwide));
dc.LineTo(ox + int(cos(Pi*angle1) * (- 2 * xwide)),
oy + int(- sin(Pi*angle1) * sin(Pi*angle2) * (-2 * xwide)));//x axis
for(k = 0;k < time; k++);
dc.MoveTo(ox + 0, oy + int(2 * ywide * cos(Pi*angle2)));
dc.LineTo(ox + 0, oy + int((-2 * ywide) * cos(Pi*angle2)));//y axis
for(k = 0;k < time; k++);
dc.MoveTo(ox + int(- sin(Pi*angle1) * 2 * zwide ),
oy + int(- cos(Pi*angle1) * sin(Pi*angle2) * 2 * zwide));
dc.LineTo(ox + int(- sin(Pi*angle1) * (-2 * zwide)),
oy + int(- cos(Pi*angle1) * sin(Pi*angle2) * (-2 * zwide)));//z axis
}
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CMy010763View diagnostics
#ifdef _DEBUG
void CMy010763View::AssertValid() const
{
CView::AssertValid();
}
void CMy010763View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMy010763Doc* CMy010763View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMy010763Doc)));
return (CMy010763Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMy010763View message handlers
void CMy010763View::Onzhengset()
{
flag = 1;
if( zheng.DoModal()==IDOK) {
angle1 = zheng.m_angle1;
angle2 = zheng.m_angle2;
time = zheng.m_time;
aa = zheng.m_zaa;
angle3 = zheng.m_zangle3;
bb = zheng.m_zbb;
c = zheng.m_zc;
cc = zheng.m_zcc;
dense = zheng.m_zdense;
e = zheng.m_ze;
ox = zheng.m_ox;
oy = zheng.m_zoy;
s = zheng.m_zs;
tx = zheng.m_ztx;
ty = zheng.m_zty;
tz = zheng.m_ztz;
xa = zheng.m_zxa;
xwide = zheng.m_zxwide;
ya = zheng.m_zya;
ywide = zheng.m_zywide;
za = zheng.m_zza;
zwide = zheng.m_zzwide;
if(bb == 0 && cc == 0) MessageBox("沿任意轴旋转变换的y,z方向不能同时为0");
else
Invalidate();
}
// TODO: Add your command handler code here
}
void CMy010763View::Ontoushiset()
{
flag = 0;
if( toush.DoModal()==IDOK) {
aa = toush.m_aa ;
angle3 = toush.m_angle3;
bb = toush.m_bb;
c = toush.m_c;
cc = toush.m_cc;
d = toush.m_d;
dense = toush.m_dense;
e = toush.m_e;
ox = toush.m_ox;
oy = toush.m_oy;
s = toush.m_s;
tx = toush.m_tx;
ty = toush.m_ty;
tz = toush.m_tz;
xa = toush.m_xa;
xwide = toush.m_xwide;
ya = toush.m_ya;
ywide = toush.m_ywide;
za = toush.m_za;
zwide = toush.m_zwide;
if(bb == 0 && cc == 0) MessageBox("沿任意轴旋转变换的y,z方向不能同时为0");
else
Invalidate();
}
// TODO: Add your command handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -