美文网首页狮猿社CATIA
CAA:如何通过两个向量生成轴系

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

作者: 锦囊喵 | 来源:发表于2020-10-27 10:02 被阅读0次

    以下代码来自 用例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三个向量成一个坐标系的三个轴向量

    相关文章

      网友评论

        本文标题:CAA:如何通过两个向量生成轴系

        本文链接:https://www.haomeiwen.com/subject/gyvtvktx.html