How do I rotate points of object



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

    On 11/04/2005 at 05:56, xxxxxxxx wrote:

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

    ---------
    How do I rotate points of object. I want to rotate axis like the object tool.
    I have read [First you have to rotate the object.Then you have to rotate the points of the object back.] I can rotate the object but what is the formula to rotate the points of it. When I run the get points command
    it comes back as a point array. when I try to rotate this I get incompatible values array/object error. Does anybody know about this? and how to fix it.



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

    On 11/04/2005 at 13:30, xxxxxxxx wrote:

    Ok figured out how to center axis of object with this code. But how do I rotate axis independent of object like object tool.

    main (doc,op)
    {
    // this finds the center of the objects points.

    var doc = GetActiveDocument();// Get Active Document
    var obj = GetActiveObject(doc); // Get Active Object

    var object = doc->GetFirstObject();
    var c, ty = vector(0.0), scale = 1.0 / float(object->GetPointCount());
    for (c=0; c<object->GetPointCount(); ++c) ty += object->GetPoint(c) * scale;
    ty = object->GetMl()->GetMulP(ty);

    // get inverted matrix of object and the translation vector to new position

    var inv = object->GetMl(); inv->Invert();
    var trans = inv->GetMulV(ty - object->GetPosition());

    // move object to a new position and consider vertex positions

    object->SetPosition(ty);
    for (c=0; c<object->GetPointCount(); ++c) {
    object->SetPoint(c, object->GetPoint(c) - trans);
    }
    object->Message(MSG_UPDATE);

    // Positions of child objects

    var child = object->GetDown();
    for (; child; child = child->GetNext()) {
        child->SetPosition(child->GetPosition() - trans);
    }
    return TRUE;
    }



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

    On 21/04/2005 at 13:41, xxxxxxxx wrote:

    Use a matrix, for example mat=HPBToMatrix(), for the transformation. Then you use do the following pseudo algorithm:

        
        
        obj->SetMl(mat*obj->GetMl());  
        mat->Invert();  
        get points  
        for (all points)  
        {  
          points[i] = mat*points[i];  
        }  
        set points
    


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

    On 21/04/2005 at 13:42, xxxxxxxx wrote:

    The same for child objects as for the points. For all children, do child->SetMl(mat*child->GetMl()).


Log in to reply