Align to Normal



  • 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



  • 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)



  • 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!


Log in to reply