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三個向量成一個坐標系的三個軸向量
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容