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

📄 wolter_convex.cpp

📁 曲面加工程序源码,用C++编写的加工曲线曲面的程序
💻 CPP
字号:
//---------------------------------------------------------------------------

#if !defined(__wolter_convex_cpp)
#define __wolter_convex_cpp

#include "wolter_convex.h"          

//---------------------------------------------------------------------------

#pragma package(smart_init)

//Difinition of wolter_convex class    20010320

#include <math.h>
#pragma hdrstop

#include "wolter_convex.h"

////Construcor and destructor
wolter_convex::wolter_convex(){

};

wolter_convex::~wolter_convex(){

};
//equations for calcuration

inline int wolter_convex::AreaJudgement(double x,double y){

   //儚乕僋偺僄儕傾傪敾掕偟丄僄儕傾ID偲偦偺揰偱偺Z嵗昗傪曉偡
   //AreaID=   0 :c1
   //          1 :1 soukyoku
   //          2 :2 houbutu
   //          3 :c2

   int judge;

   if (x<-130.){
    return 0;
   }else if (x<0){
    return 1;
   }else if (x<130){
    return 2;
   }else {
    return 3;
   }

};

inline double wolter_convex::GetZ( double x, double y){

   double z;

   //AreaID=   0 :c1
   //          1 :1 soukyoku
   //          2 :2 houbutu
   //          3 :c2

   switch (AreaJudgement(x,y)){

       case 0:           //c1
           z = -100. + sqrt(9593.2447914 - powl(y,2));
           break;

       case 1:           //1
           z = -100. + sqrt(powl(0. + sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2)),2) -
     powl(y,2));
           break ;

       case 2:           //2
           z = -100. + sqrt(powl(0. + sqrt(10000. + 1.0524861*x),2) - powl(y,2));
           break ;

       case 3:           //c2
           z = -100. + sqrt(10136.823193 - powl(y,2));
           break ;

       default:
           z = 0;

   };

   return z;

   //z=0 ,when x=y=0.

};

inline vector wolter_convex::GetPosition( double x, double y){
	return ( vector( x, y, GetZ(x,y) ) );
};

inline double wolter_convex::gradX(double x, double y){

   double dz;

   //AreaID=   0 :c1
   //          1 :1 soukyoku
   //          2 :2 houbutu
   //          3 :c2

   switch (AreaJudgement(x,y)){

       case 0:           //c1
           dz = 0;
           break;

       case 1:           //1
           dz = ((3.1576911 + 0.0004431519999999999*x)*
     (0. + sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2))))/
   (2.*sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2))*
     sqrt(powl(0. + sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2)),2) -
       powl(y,2)));
           break ;

       case 2:           //2
           dz = (0.52624305*(0. + sqrt(10000. + 1.0524861*x)))/
   (sqrt(10000. + 1.0524861*x)*sqrt(powl(0. + sqrt(10000. + 1.0524861*x),2) - powl(y,2)));
           break ;

       case 3:           //c2
           dz = 0;
           break ;

       default:
           dz = 0;

   };

   return dz;

   //z=0 ,when x=y=0.

};

inline double wolter_convex::gradY(double x, double y){

   double dz;

   //AreaID=   0 :c1
   //          1 :1 soukyoku
   //          2 :2 houbutu
   //          3 :c2

   switch (AreaJudgement(x,y)){

       case 0:           //c1
           dz = -y/sqrt(9593.2447914 - powl(y,2));
           break;

       case 1:           //1
           dz = -y/sqrt(powl(0. + sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2)),2) -
     powl(y,2));
           break ;

       case 2:           //2
           dz = -y/sqrt(powl(0. + sqrt(10000. + 1.0524861*x),2) - powl(y,2));
           break ;

       case 3:           //c2
           dz = -y/sqrt(10136.823193 - powl(y,2));
           break ;

       default:
           dz = 0;

   };

   return dz;

   //z=0 ,when x=y=0.


};

inline double wolter_convex::gradXX(double x, double y){

   double dz;

   //AreaID=   0 :c1
   //          1 :1 soukyoku
   //          2 :2 houbutu
   //          3 :c2

   switch (AreaJudgement(x,y)){

       case 0:           //c1
           dz = 0;
           break;

       case 1:           //1
           dz = (powl(3.1576911 + 0.0004431519999999999*x,2)*
      powl(0. + sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2)),2))/
    (4.*(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2))*
      powl(powl(0. + sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2)),2) -
        powl(y,2),1.5)) - powl(3.1576911 + 0.0004431519999999999*x,2)/
    (4.*(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2))*
      sqrt(powl(0. + sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2)),2) -
        powl(y,2))) - (powl(3.1576911 + 0.0004431519999999999*x,2)*
      (0. + sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2))))/
    (4.*powl(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2),1.5)*
      sqrt(powl(0. + sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2)),2) -
        powl(y,2))) + (0.0002215759999999999*
      (0. + sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2))))/
    (sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2))*
      sqrt(powl(0. + sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2)),2) -
        powl(y,2)));

           break ;

       case 2:           //2
           dz = (0.2769317476733025*powl(0. + sqrt(10000. + 1.0524861*x),2))/
    ((10000. + 1.0524861*x)*powl(powl(0. + sqrt(10000. + 1.0524861*x),2) - powl(y,2),
       1.5)) - 0.2769317476733025/
    ((10000. + 1.0524861*x)*sqrt(powl(0. + sqrt(10000. + 1.0524861*x),2) - powl(y,2))) -
   (0.2769317476733025*(0. + sqrt(10000. + 1.0524861*x)))/
    (powl(10000. + 1.0524861*x,1.5)*
      sqrt(powl(0. + sqrt(10000. + 1.0524861*x),2) - powl(y,2)));
      break ;

       case 3:           //c2
           dz = 0;
           break ;

       default:
           dz = 0;

   };

   return dz;

   //z=0 ,when x=y=0.


};

inline double wolter_convex::gradYY(double x, double y){


   double dz;

   //AreaID=   0 :c1
   //          1 :1 soukyoku
   //          2 :2 houbutu
   //          3 :c2

   switch (AreaJudgement(x,y)){

       case 0:           //c1
           dz = -powl(y,2)/powl(9593.2447914 - powl(y,2),1.5) - 1/sqrt(9593.2447914 - powl(y,2));
           break;

       case 1:           //1
           dz = -powl(y,2)/powl(powl(0. + sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2)),
       2) - powl(y,2),1.5) + 1/
    sqrt(powl(0. - sqrt(10000. + 3.1576911*x + 0.0002215759999999999*powl(x,2)),2) - 
      powl(y,2));
           break ;

       case 2:           //2
           dz = -powl(y,2)/powl(powl(0. + sqrt(10000. + 1.0524861*x),2) - powl(y,2),1.5) +
   1/sqrt(powl(0. - sqrt(10000. + 1.0524861*x),2) - powl(y,2));
           break ;

       case 3:           //c2
           dz = -powl(y,2)/powl(10136.823193 - powl(y,2),1.5) - 1/sqrt(10136.823193 - powl(y,2));
           break ;

       default:
           dz = 0;

   };

   return dz;

   //z=0 ,when x=y=0.

};

// This is the normal vector of surface on the point(x,y).
// This is toward the inside of wolter_convex.
// This.length is 1.
vector wolter_convex::NormalVector ( double x, double y){
	return ( vector( -gradX(x,y), -gradY(x,y), 1).normalize() );  //OK 980520
};
vector wolter_convex::NormalVector ( vector position){
	return ( NormalVector( position.getX(), position.getY() ) );
};

////GradientVector////////////////////////////////////////////
// This is one of tangential vactors on the tangential plane.
// This is toward direction which has the largest gradient.
// This length is 1.
vector wolter_convex::GradientVector(double x, double y){
	double gx = gradX( x,y);
	double gy = gradY( x,y);

	return ( vector( gx, gy, gx*gx+gy*gy ).normalize() );
};
vector wolter_convex::GradientVector( vector position){
	return( GradientVector( position.getX(), position.getY() ) );
};

////NoGradientVector///////////////////////////////////////////
// This is one of tangential vactors on the tangential plane.
// This is toward direction which has no gradient.
//// This length will be 1,
//// and this Z-coordinate will be Zero.
vector wolter_convex::NoGradientVector(double x,double y){
	return( NormalVector(x,y)%GradientVector(x,y) );
};
vector wolter_convex::NoGradientVector(vector position){
	return( NormalVector(position)%GradientVector(position) );
};


int wolter_convex::WriteFaceName(ofstream& fout){

	fout << "(Face name is : wolter_convex);" << endl;
	return(1);
};
int wolter_convex::WriteParameters(ofstream& fout){


	return(1);
};


void wolter_convex::SetParameter(TStringList *str)
{
   for (int i=0; i<str->Count; i++){


         //isConcave
   };
   face::SetFaceParameter(str);
};

void wolter_convex::GetParameter(TStringList *str)
{

   str->Add(AnsiString("---wolter_convex parameter(s)---"));
   str->Add(AnsiString("FaceType=wolter_convex"));

   face::GetFaceParameter(str);
};

#endif


⌨️ 快捷键说明

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