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
    • Recent
    • Tags
    • Users
    • Register
    • Login

    Align to Normal

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 318 Views
    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 Offline
      Helper
      last edited by

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

      On 16/03/2005 at 07:53, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   9.1 
      Platform:   Windows  ; Mac  ;  Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      Hi,

      I have a problem. I get the normal of a polygon with CalcFaceNormal(). Then I construct a rotation matrix out of it and set it to an object to align it to that normal.

      Works fine so far, but the normal gives me headaches. If I rotate the polygon around 1 axis, the whole normal changes (so all 3 components), which means the constructed matrix has rotations in other axis too, which results in the object to rotate around other axis although the normal has only been rotated around 1 axis.

      Anybody knows how to solve this? Any ideas?

      Thank you very much!
      Katachi

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

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

        On 17/03/2005 at 11:45, xxxxxxxx wrote:

        you need to construct your matrix with an upvector. if you need your object to stick to the surface then you could try using !(padr[vadr[0]]-padr[vadr[2]]) as your upvector, this will ensure (provided the winding doesn't change) that you have a constant relative upvector

        then just construct your matrix as follows:

        mat.v3=normal;
        mat.v2=upvector;
        mat.v1=normal%upvector;
        (you might wanna do cross products on the other two afterwards just to make sure that the matrix is orthogonal)

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

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

          On 17/03/2005 at 11:48, xxxxxxxx wrote:

          Ah! Good idea with using the points as upvector! (why didn´t I think of this? 🙂
          The matrix construction is clear.

          Thanks!

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