Coffee problem with angles



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/01/2003 at 16:19, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   8.012 
    Platform:   Windows  ;   
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    Hello!
    I´m trying to adjust a polygon of an object to a polygon of another object. For this I have to rotate one of the objects. I have calculated the normals of this polys and with VectorToHPB the corresponding angles. Unfortunately my math isn´t good enough to know what to do with this angles to get the rotation of the object right. Taking the difference doesn´t quite work. I think I should use this difference to calculate new HPB angles. But how is this done?
    Thanks in advance



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 16/01/2003 at 17:48, xxxxxxxx wrote:

    The resulting rotation isn't uniquely defined, since you could always add a bank along the parallel normals. I think the easiest way to get a solution is to first calculate the cross product of the normals (to get the rotation axis), then take the arc-sine of the length of the axis (to get the angle between the normals) and finally use Matrix::SetRotAxis() to get a transformation matrix: (Untested code.)

        
        
          
        var obj1 = ...;  
        var obj2 = ...;  
          
        var normal1 = ...;  
        var normal2 = ...;  
          
        var axis = vcross(normal1, normal2);  
        var angle = asin(vlen(axis));  
          
        var mat = new(Matrix);  
        mat->SetRotAxis(axis, angle);  
          
        obj2->SetMg(mat->GetMulM(obj->GetMg()));  
        
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 19/01/2003 at 16:18, xxxxxxxx wrote:

    Thanks alot. That did it.


Log in to reply