📄 parabo.cpp
字号:
#if !defined(__parabo_cpp)
#define __parabo_cpp
//Difinition of paraboloid class
#include <math.h>
#pragma hdrstop
#include "parabo.h"
////Construcor and destructor
paraboloid::paraboloid(){
p=P_INIT;
};
paraboloid::paraboloid( double pp){
p=pp;
};
paraboloid::~paraboloid(){
};
////accessor
/*void paraboloid::SetParameters(){
p = InputParameter("Focal Distance[mm]",500,0.01,1000);
face::SetFaceParameters();
};
//980519
*/
inline void paraboloid::SetFocalDistance(double pp ){ p=pp; };
inline double paraboloid::GetFocalDistance() {return(p);};
inline double paraboloid::GetZ( double x, double y){
return ( (x*x+y*y)/(4.0*p) );
};
inline vector paraboloid::GetPosition( double x, double y){
return ( vector( x, y, GetZ(x,y) ) );
};
inline double paraboloid::gradX(double x, double y){
return( x/(2.0*p) );
};
inline double paraboloid::gradY(double x, double y){
return( y/(2.0*p) );
};
inline double paraboloid::gradXX(double x, double y){
return( 1/(2.0*p) );
};
inline double paraboloid::gradYY(double x, double y){
return( 1/(2.0*p) );
};
// This is the normal vector of surface on the point(x,y).
// This is toward the inside of paraboloid.
// This.length is 1.
vector paraboloid::NormalVector ( double x, double y){
return ( vector( -gradX(x,y), -gradY(x,y), 1).normalize() );
};
vector paraboloid::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 paraboloid::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 paraboloid::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 paraboloid::NoGradientVector(double x,double y){
return( NormalVector(x,y)%GradientVector(x,y) );
};
vector paraboloid::NoGradientVector(vector position){
return( NormalVector(position)%GradientVector(position) );
};
int paraboloid::WriteFaceName(ofstream& fout){
fout << "(Face name is : Paraboloid);" << endl;
return(1);
};
int paraboloid::WriteParameters(ofstream& fout){
fout << "(,which focal distance[mm] is :" << p <<");" << endl;
return(1);
};
/*
void paraboloid::SetParameters(){
p = InputParameter("Focal Distance[mm]",500,0.01,1000);
face::SetFaceParameters();
};
void SetParameter(TStringList str);
void GetParameter(TStringList &str);
*/
void paraboloid::SetParameter(TStringList *str)
{
for (int i=0; i<str->Count; i++){
AnsiString temp;
temp = "FocalDistance";
if (str->Names[i]==temp){
p = str->Values[str->Names[i]].ToDouble();
};
};
face::SetFaceParameter(str);
};
void paraboloid::GetParameter(TStringList *str)
{
str->Add(AnsiString("---paraboroid parameter(s)---"));
str->Add(AnsiString("FaceType=paraboloid"));
str->Add(AnsiString("FocalDistance=")+ p);
face::GetFaceParameter(str);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -