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

    var m = new(Matrix); in Python?

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 319 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

      On 25/03/2013 at 15:39, xxxxxxxx wrote:

      I'm currently looking over some coffee scripts and looking at taking some of the tips in them into python. Could someone please shine some light on or help me re-write this coffee script snippet into python?
      I'm getting stuck on m = new(Matrix)?

      	var mobj = Object->GetMg();
      	var tobj = Target->GetMg();
      	var oldrot, newrot;	
        
      	var p1 = mobj->GetV0();
      	var p2 = tobj->GetV0();
        
      	var m = new(Matrix);
        
      	m->SetV0(p1); 
      	m->SetV3(vnorm(p2 - p1)); 
      	m->SetV2(vnorm(vcross(p2-p1, vector(0,1,0)))); 
      	m->SetV1(vnorm(vcross(p2-p1, vector(0,0,1)))); 
      		
      	newrot=m->GetHPB();
      	var	orot=mobj->GetHPB();
      	newrot.z=orot.z;
      	oldrot=mobj->GetHPB();
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 25/03/2013 at 16:10, xxxxxxxx wrote:

        mobj = Object.GetMg()
        tobj = Target.GetMg()  
        oldrot = newrot = c4d.Vector() #Not important	
          
        p1 = mobj.off  
        p2 = tobj.off
          
        m = c4d.Matrix()
          
        m.off = p1   
        m.V3 = (p2 - p1).GetNormalized())  
        m.V2 = (p2-p1).Cross(c4d.Vector(0,1,0)).GetNormalized())  
        m.V1 = (p2-p1).Cross(c4d.Vector(0,0,1)).GetNormalized())
          
        newrot = c4d.utils.MatrixToHPB(m)  
        orot = c4d.utils.MatrixToHPB(mobj)  
        newrot.z = orot.z
        oldrot = c4d.utils.MatrixToHPB(mobj)
        

        Should look like this.
        Greeting
        rown

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

          On 25/03/2013 at 16:16, xxxxxxxx wrote:

          Ah thanks, thats a big help, thanks Rown.

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