⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 specioperation.cpp

📁 moto e2键盘软锁第三版
💻 CPP
字号:
// SpeciOperation.cpp: implementation of the SpeciOperation class.
//
//////////////////////////////////////////////////////////////////////
#include "SpeciOperation.h"
#include "math.h"
#include <stdio.h>#include <stdlib.h>#include <qpoint.h>
#include <iostream.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

SpeciOperation::SpeciOperation()
{

}

SpeciOperation::~SpeciOperation()
{

}

void SpeciOperation::matrixSetIdentity(float m[][3])
{
	int i,j;
	for(i=0;i<3;i++)
		for(j=0;j<3;j++)
			m[i][j]=(i==j);
}

void SpeciOperation::matrixPreMultiply(float a[][3],float b[][3])
{
	int r,c;
	float t[3][3];
	for(r=0;r<3;r++)
		for(c=0;c<3;c++)
			t[r][c]=a[r][0]*b[0][c]+a[r][1]*b[1][c]+a[r][2]*b[2][c];
	for(r=0;r<3;r++)
		for(c=0;c<3;c++)
			b[r][c]=t[r][c];
}
/*
void SpeciOperation::translate(int tx, int ty)
{
	matrixSetIdentity(theMatrix);
	float m[3][3];
	matrixSetIdentity(m);
	m[0][2]=tx;
	m[1][2]=ty;
	matrixPreMultiply(m,theMatrix);

}

void SpeciOperation::scale(float sx, float sy, float x, float y)
{
	matrixSetIdentity(theMatrix);

	float m[3][3];
	matrixSetIdentity(m);
	m[0][0]=sx;
	m[0][2]=(1-sx)*x;
	m[1][1]=sy;
	m[1][2]=(1-sy)*y;
	matrixPreMultiply(m,theMatrix);
}
*/
void SpeciOperation::rotate(float a, float x, float y)
{
matrixSetIdentity(theMatrix);
	float m[3][3];
	matrixSetIdentity(m);
	a=a*(3.14/180);
	m[0][0]=cos(a);
	m[0][1]=-sin(a);
	m[0][2]=x*(1-cos(a))+y*sin(a);	
	m[1][0]=sin(a);
	m[1][1]=cos(a);
	m[1][2]=y*(1-cos(a))-x*sin(a);
	matrixPreMultiply(m,theMatrix);
}

void SpeciOperation::Change(QPoint &ap, QPoint &bp, int style)
{point a,b;a.x=ap.x();a.y=ap.y();b.x=bp.x();b.y=bp.y();
float aa=(float)a.x;float bb=(float)a.y;float cc=(float)b.x;float dd=(float)b.y;
	switch(style)
	{
	case 1:
		a.x+=theMatrix[0][2];
		a.y+=theMatrix[1][2];
		b.x+=theMatrix[0][2];
		b.y+=theMatrix[1][2];
		break;
	case 2:
		a.x=a.x*theMatrix[0][0]+theMatrix[0][2];
		a.y=a.y*theMatrix[1][1]+theMatrix[1][2];
		b.x=b.x*theMatrix[0][0]+theMatrix[0][2];
		b.y=b.y*theMatrix[1][1]+theMatrix[1][2];
		break;
	case 3:
		a.x=aa*theMatrix[0][0]+bb*theMatrix[0][1]+theMatrix[0][2];
		a.y=aa*theMatrix[1][0]+bb*theMatrix[1][1]+theMatrix[1][2];
		b.x=cc*theMatrix[0][0]+dd*theMatrix[0][1]+theMatrix[0][2];
		b.y=cc*theMatrix[1][0]+dd*theMatrix[1][1]+theMatrix[1][2];
		break;
	default:
		break;
	} 
}

void SpeciOperation::Change(int &ax, int &ay, int style)
{
		int aa=ax,bb=ay;
	switch(style)
	{
	case 1:
		ax+=theMatrix[0][2];
		ay+=theMatrix[1][2];
		
		break;
	case 2:
		ax=ax*theMatrix[0][0]+theMatrix[0][2];
		ay=ay*theMatrix[1][1]+theMatrix[1][2];
		
		break;
	case 3:
		ax=aa*theMatrix[0][0]+bb*theMatrix[0][1]+theMatrix[0][2];
		ay=aa*theMatrix[1][0]+bb*theMatrix[1][1]+theMatrix[1][2];
		
		break;
	default:
		break;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -