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

    Dot(v1, v2) = Gibberish?

    SDK Help
    0
    3
    233
    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
      Helper
      last edited by

      On 22/11/2013 at 11:36, xxxxxxxx wrote:

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

      ---------
      I'm getting very strange values out of the Dot() SDK function.
      According to the internet. My hand calculated results are correct. And the result from Dot() is not.

      What's going on with this function?

      Example #1

          LVector a = (2, 3, 4);  
        LVector b = (1,-2, 3);  
        
      /*  Calculating the dot product myself by hand  
        2*1 + 3*-2 + 4*3  
        2   +  -6  \+ 12  
        8 <--The answer  
      */  
        
        LReal dot = Dot(a,b);           //<---returns 36! why?  
        GePrint(RealToString(dot));
      

      Example #2

          LVector a2 = (4, 8, 10);  
        LVector b2 = (9, 2, 7);  
        
      /*  Calculating the dot product myself by hand  
        4*9 + 8*2 + 10*7  
        36  \+ 16 + 70  
        122 <--The answer  
      */  
        
        LReal dot2 = Dot(a2,b2);       //<---returns 210! why?  
        GePrint(RealToString(dot2));
      

      -ScottA

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

        On 22/11/2013 at 12:06, xxxxxxxx wrote:

        I think this must look like this :

          
            
            
                LVector a = (2, 3, 4);  //set x,y,z to 4  
              LVector b = (1,-2, 3);  //set x,y,z to 3  
              
                // Calculating the dot product myself by hand  
                // 4*3+4*3+4*3  
              // 36 <--The answer  
              
              LReal dot = Dot(a,b);           //<---returns 36! why?  
              GePrint(RealToString(dot));
        

        So the answer is correct.

        But you problem is this:

          
            
            
             LVector a = (2, 3, 4);  //the same as LVector a = LVector(4);
        

        So here is the code that work as expected:

          
            
            
                LVector a(2, 3, 4); //or LVector a = LVector(2,3,4);  
              LVector b(1,-2, 3);  
              
                // Calculating the dot product myself by hand  
                // 2*1 + 3*-2 + 4*3      
                // 8 <--The answer  
              
              LReal dot = Dot(a,b);           //<---returns 8!  
              GePrint(RealToString(dot));
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 22/11/2013 at 12:35, xxxxxxxx wrote:

          Oh. I get it now.
          Thanks Remo.

          -ScottA

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