70,021
社区成员




/// <summary>
/// 获取查询字符串
/// </summary>
string GetQueryStr()
{
string str = " From T_PRC_Process as a "
+ " inner join T_BAS_WorkCenter as b on a.WorkCenterID=b.WorkCenterID "
+ " inner join T_PRC_PartSpecPara as c on a.PartSpecParaID=c.PartSpecParaID "
+ " inner join T_BAS_Bearing as d on a.BearingID=d.BearingID "
+ " inner join T_BAS_ForgePrcType as e ON a.FgPrcTypeID = e.FgPrcTypeID "
+ " left join T_PRC_ForgeFactoryProcess as f on a.ProcessID=IsNull(f.ProcessID,'') "
+ " left join T_BAS_ForgeFactory as g on IsNull(f.ForgeFactoryID,'')=IsNull(g.ForgeFactoryID,'') ";
return str;
}
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.1415926535897931
char *GetQueryStr()
{
char *str;
str = (char *)malloc(1024*sizeof(char));
if(str == NULL) {
printf("malloc error!\n");
return NULL;
}
sprintf(str, " From T_PRC_Process as a "
" inner join T_BAS_WorkCenter as b on a.WorkCenterID=b.WorkCenterID "
" inner join T_PRC_PartSpecPara as c on a.PartSpecParaID=c.PartSpecParaID "
" inner join T_BAS_Bearing as d on a.BearingID=d.BearingID "
" inner join T_BAS_ForgePrcType as e ON a.FgPrcTypeID = e.FgPrcTypeID "
" left join T_PRC_ForgeFactoryProcess as f on a.ProcessID=IsNull(f.ProcessID,'') "
" left join T_BAS_ForgeFactory as g on IsNull(f.ForgeFactoryID,'')=IsNull(g.ForgeFactoryID,'') ");
return str;
}
/// <summary>
/// 计算2条直线的相交点
/// </summary>
double *GetLineInt(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4)
{
double *p1 = (double *)malloc(3*sizeof(double));
if(p1 == NULL) {
printf("malloc error!\n");
return NULL;
}
double x5, y5;
if(((x3 - x4) * (y1 - y2) - (x1 - x2) * (y3 - y4)) != 0) {
x5 = ((x1 - x2) * (x3 * y4 - x4 * y3) - (x3 - x4) * (x1 * y2 - x2 * y1)) / ((x3 - x4) * (y1 - y2) - (x1 - x2) * (y3 - y4));
y5 = ((y1 - y2) * (x3 * y4 - x4 * y3) - (x1 * y2 - x2 * y1) * (y3 - y4)) / ((y1 - y2) * (x3 - x4) - (x1 - x2) * (y3 - y4));
p1[0] = x5;
p1[1] = y5;
p1[2] = 0;
return p1;
}
else {
free(p1);
return NULL;
}
}
/// <summary>
/// 描 述:获取线的角度
/// </summary>
double GetLineAngle(double *lineStartPoint,double *lineEndPoint)
{
if(lineStartPoint[0]==lineEndPoint[0]) {
return PI/2;
}
else {
return atan( (lineStartPoint[1]-lineEndPoint[1])/(lineStartPoint[0]-lineEndPoint[0]) );
}
}
/// <summary>
/// 描 述:获取线的方向,H 纵线,W 横线,S 斜线
/// </summary>
char GetLineDirection(double *p1,double *p2)
{
if (fabs(p1[0] - p2[0]) < 1e-9 ) {//纵线
return 'H';
}
else if (fabs(p1[1] - p2[2]) < 1e-9 ) {//横线
return 'W';
}
else {//斜线
return 'S';
}
}
/// <summary>
/// 描 述:获取一个点在线上的垂直点位置
/// </summary>
double *GetPointToLineVerticalPoint(double *point,double *lineStartPoint,double *lineEndPoint)
{
double *vp = (double *)malloc(3*sizeof(double));
char lineDirection;
if(vp == NULL) {
printf("malloc error!\n");
return NULL;
}
lineDirection = GetLineDirection(lineStartPoint,lineEndPoint);
if (lineDirection=='H') {//纵线
vp[0]=lineStartPoint[0];
vp[1]=point[1];
}
else if (lineDirection=='W') {//横线
vp[0]=point[0];
vp[1]=lineStartPoint[1];
}
else {//斜线
//先求ab的斜率
double k0 =(lineEndPoint[1]-lineStartPoint[1])/(lineEndPoint[0]-lineStartPoint[0]);
//其垂线的斜率为
double k1 = - 1/k0;
//垂足坐标:
double x=(point[1]-lineStartPoint[1]+lineStartPoint[0]*k0-point[0]*k1)/(k0-k1);
double y=point[1]+(x-point[0])*k1;
vp[0]=x;
vp[1]=y;
}
return vp;
}
Math.PI //圆的派值,就是3.145555那个
Math.Atan //返回正切值为指定数字的角度
Math.Round //舍弃小数的方法,第一个是小数值,第二个是精确到多少位
1.
//不考虑线程安全
char * GetQueryStr()
{
static char str[] = " From T_PRC_Process as a "
" inner join T_BAS_WorkCenter as b on"
" a.WorkCenterID=b.WorkCenterID "
" inner join T_PRC_PartSpecPara as c on "
" a.PartSpecParaID=c.PartSpecParaID "
" inner join T_BAS_Bearing as d on a.BearingID=d.BearingID "
" inner join T_BAS_ForgePrcType as e ON a.FgPrcTypeID ="
" e.FgPrcTypeID "
" left join T_PRC_ForgeFactoryProcess as f on a.ProcessID="
" IsNull(f.ProcessID,'') "
" left join T_BAS_ForgeFactory as g on ""
"IsNull(f.ForgeFactoryID,'')=IsNull(g.ForgeFactoryID,'') ";
return str;
}
-------------------------------------------------------------------------------------
2.
double* GetLineInt(double x1,double y1,double x2,double y2,double x3,
double y3,double x4,double y4)
{
double * p1;
double x5;
double y5;
p1 = (double *)malloc(sizeof(double)*3);
if(((x3 - x4) * (y1 - y2) - (x1 - x2) * (y3 - y4)) != 0)
{
x5 = ((x1 - x2) * (x3 * y4 - x4 * y3) - (x3 - x4) * (x1 * y2 - x2 * y1)) /
((x3 - x4) * (y1 - y2) - (x1 - x2) * (y3 - y4));
y5 = ((y1 - y2) * (x3 * y4 - x4 * y3) - (x1 * y2 - x2 * y1) * (y3 - y4)) /
((y1 - y2) * (x3 - x4) - (x1 - x2) * (y3 - y4));
p1[0] = x5;
p1[1] = y5;
p1[2] = 0;
return p1;
}
else
{
delete[] p1;//需要释放空间
return NULL;
}
}
string GetQueryStr()
{
string str = " From T_PRC_Process as a "
+ " inner join T_BAS_WorkCenter as b on a.WorkCenterID=b.WorkCenterID "
+ " inner join T_PRC_PartSpecPara as c on a.PartSpecParaID=c.PartSpecParaID "
+ " inner join T_BAS_Bearing as d on a.BearingID=d.BearingID "
+ " inner join T_BAS_ForgePrcType as e ON a.FgPrcTypeID = e.FgPrcTypeID "
+ " left join T_PRC_ForgeFactoryProcess as f on a.ProcessID=IsNull(f.ProcessID,'') "
+ " left join T_BAS_ForgeFactory as g on IsNull(f.ForgeFactoryID,'')=IsNull(g.ForgeFactoryID,'') ";
return str;
}
---------------------------------------------------------------------------------------
2.
/// <summary>
/// 计算2条直线的相交点
/// </summary>
double* GetLineInt(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4)
{
double* p1 = new double[3] ;
double x5;
double y5;
if(((x3 - x4) * (y1 - y2) - (x1 - x2) * (y3 - y4)) != 0)
{
x5 = ((x1 - x2) * (x3 * y4 - x4 * y3) - (x3 - x4) * (x1 * y2 - x2 * y1)) / ((x3 - x4) * (y1 - y2) - (x1 - x2) * (y3 - y4));
y5 = ((y1 - y2) * (x3 * y4 - x4 * y3) - (x1 * y2 - x2 * y1) * (y3 - y4)) / ((y1 - y2) * (x3 - x4) - (x1 - x2) * (y3 - y4));
p1[0] = x5;
p1[1] = y5;
p1[2] = 0;
return p1;
}
else
{
delete[] p1;//需要释放空间
return NULL;
}
}