CAA:如何通过两个向量生成轴系

以下代码来自 用例CAAMthBase ,属于 CAAMathematics.edu 框架,路径如下:

Windows InstallRootDirectory\CAAMathematics.edu\CAAMthBase.m
Unix InstallRootDirectory/CAAMathematics.edu/CAAMthBase.m/


CATMathPoint    O, A(20. ,10. ,0.) ; // Default constructor, O is (0.,0.,0.)
    
CATMathVector u(10., 20. ,0.);
u.Normalize();                     // Normalize u;
    
// H: Orthogonal projection of A on the line (O,u): 
// Use the operators 
// A-O is a vector, (A-O)*u the dot product
//
CATMathVector OA = A - O ;
CATMathPoint  H  = O + ( OA*u ) * u;
 
// Computes the normal of the two vectors (A-O) and u: ^ is the cross product
CATMathVector n  = OA ^ u;      
    
//
// Another way to project to get H: 
// use the Project method of the CATMathLine class. 
//
CATMathLine  line(O,u);
CATMathPoint projection;
line.Project( A , projection );
     
// Returns the distance between the two computed points. 
//If non nul, it is an error.
        
if ( H.SquareDistanceTo( projection ) != 0.  ) return (1);
    
// Outputs the coordinates of the projected points
double aCoord[3];
H.GetCoord( aCoord );
cout << "coordinates of the projected point : " 
        << aCoord[0] << "\t" 
        << aCoord[1] << "\t"
        << aCoord[2] << endl;

注意 这一句:

CATMathPoint  H  = O + ( OA*u ) * u;
假设 向量OA、u有夹角,且不为90度,则OA,OAu,(OAu)*u三个向量成一个坐标系的三个轴向量
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容