how to compute axis of a polygon?



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

    On 26/03/2009 at 08:17, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:    
    Platform:      
    Language(s) :

    ---------
    Hi,

    i have a mathematical problem, maybe someone here has an idea ;-)

    When you are in poly-mode and select a polygon, there will be an axis drawn onto the poly.
    How would i be able to compute that axis myself, if i only have the polyPoints and its normal.

    The poly normal would be the z-axis ofc, but how would i get the y-axis of the polygon, which then would allow me to compute the x-axis ?

    There are ofc unlimited possibilities to arrage the x and y axes on the poly-plane, while both are perepndicular to the z-axis and each other, but what i want is the same orientation that you get when you select a poly in c4d.
    Ofc this must work for arbitrary orientations of the poly in space...

    Maybe i have to rotate the poly so that it is perpendicular to a world plane, then get the needed axis and then rotate it back or sth.. ?

    greetings,
    Daniel



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

    On 26/03/2009 at 14:15, xxxxxxxx wrote:

    As you say, there is an infinite number of possible frames.
    I am not sure how this is done in C4D, but one guess is that the edges of the polygon might be used to define the frame. For example, the vector v2-v1 between the first two vertices v1 and v2 of the polygon might be the x-axis you are looking for. Again, I'm just guessing here.
    regards
    /Filip



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

    On 26/03/2009 at 14:25, xxxxxxxx wrote:

    Did a quick test. Seems like my guess wasn't right.



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

    On 26/03/2009 at 15:14, xxxxxxxx wrote:

    Howdy,

    I think the way Cinema is doing it is trying to keep the Y axis as close to pointing to world up as possible. To test this, I created a single polygon object, selected the polygon in Polygons mode and used the rotate tool to rotate the selected polygon. That's when I noticed the Y axis of the manipulator trying to point to world up as I rotated the polygon. ;o)

    Adios,
    Cactus Dan



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

    On 26/03/2009 at 17:49, xxxxxxxx wrote:

    Nope. None of these. I did some tests and the x-axis of the object and the polygon normal are correlated. If you change the object's axis with the Axis tool, the polygon axes change accordingly. So, it seems to be some rotational transform between the object's axis with respect to the polygon's normal (even with axial rotation using the Axis Tool!).



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

    On 27/03/2009 at 04:36, xxxxxxxx wrote:

    Hi,

    thanks for your input everybody.

    I was actually thinking the same as Cactus Dan, but Robert is right as well. Atm it looks to me as if the poly's y-axis is trying to match its objects y axis closest as possible.. Which would be the combination of all observations ;-)

    ill try to compute a vector on the poly with has a minimal angle diff to the objects y axis and see if thats what im looking for.

    greetings,
    Daniel



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

    On 27/03/2009 at 04:39, xxxxxxxx wrote:

    also i wonder what i'd get if i was to average all edge direction vectors of the poly, or alternatively average only those of opposing edges..

    cannot see it in my head atm, maybe ill just give it a try..



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

    On 27/03/2009 at 04:40, xxxxxxxx wrote:

    I'll see if I can get some info from the developers on how CINEMA 4D calculates the modeling axis.

    cheers,
    Matthias



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

    On 27/03/2009 at 05:37, xxxxxxxx wrote:

    that'd be awesome, thanks!



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

    On 27/03/2009 at 07:55, xxxxxxxx wrote:

    just had another idea:

    if i attach a plane which is parallel to the world-ground-plane to the center of the polygon, the intersection
    between the attached plane and the poly would be my poly- x-Axis i think..



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

    On 27/03/2009 at 08:21, xxxxxxxx wrote:

    .. which would actually mean i only have to compute the cross of the poly normal and (0,1,0) (the ground plane normal)..



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

    On 27/03/2009 at 08:38, xxxxxxxx wrote:

    I don't think the edge vectors play a part. Create a sphere, make it editable, go into Polygon mode, select a polygon, and rotate it (Rotate Tool). Go back to the Move Tool and note that the displayed axes do not change.

    I agree with the planar idea. Take the X-Y plane* of the object's axis as one plane and the polygon plane as the other. There must be a coordinate system transform from one plane to the other that replicates the C4D polygon axis (no idea how this would work with non-planar polygons though).

    My first guess would be determing a plane-plane angle to create a rotation matrix (or a plane-plane transform) applied to the axial unit vectors of the object axis. Position is of course simply determined by the polygon's centroid. Time to dig through those 3D math books. :)

    * Sorry about previous references to the X-axis - it is the Z-axis that matches the polygon normal.



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

    On 04/04/2009 at 09:35, xxxxxxxx wrote:

    Hi,

    just to finish this up (at least from my point of view ;-) ), i did it now the way i described in my last post:

    Vector polyXAxisDirection = Vector(0,1,0) % polyNormal;

    This is very simple and gives me just what i need, an xAxis on a polygon, which would never cross the world ground-plane, if it was infinite.

    I have not verified if this behaves the same as c4d's way of computing the poly-axis, but it fits my purpose exactly.

    thanks all.
    Daniel


Log in to reply