Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Coffee problem with angles

    SDK Help
    0
    3
    529
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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()));  
            
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post