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

    SplineObject->UniformTonatural prob

    SDK Help
    0
    4
    350
    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

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

      On 17/06/2004 at 01:54, xxxxxxxx wrote:

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

      ---------
      Hi.
      I write a function, that calculate a global position and tangent on spline object (s. below).
      Here came the problem:
      if the spline type is not "linear" and have some curves, than are the calculated positions on spline not uniform (dont have same length on spline between)!
      Sure, the variable "fWay" is always increase by the same value.
      Where is the problem?

      POSDIR posdirWayToSplinePosDir( SplineObject* pobjMain,
           const Real fWay, const Real fStartPos)
      {
           POSDIR posdirOutput;
           posdirOutput.vectPos= Vector(0);
           posdirOutput.vectDir= Vector(0);
           
           /*
                if (!pobjMain)
                {
                     return posdirOutput;
                }
                else if (pobjMain->GetType()!=Ospline)
                {
                     return posdirOutput;
                }
                else
           */ // NOTE: trust the caller -> pointer check disabled
           
           if (!pobjMain->InitLength(0, NULL)) // use only the 1st segment
           {
                return posdirOutput;
           }
           
           Real fSplNatPos=
                pobjMain->UniformTonatural(fWay/pobjMain->GetLength() + fStartPos);
                // natural position spline
                // TODO: to implementate loop mode -> here is the place ( modulo operation)
           Matrix matrSplGlob= pobjMain->GetMg(); // get the global matrix of...
           posdirOutput.vectPos= pobjMain->GetSplinePoint(fSplNatPos, 0, NULL) * matrSplGlob;
                // local to global coorditates convert
           posdirOutput.vectDir= pobjMain->GetSplineTangent(fSplNatPos, 0, NULL) ^ matrSplGlob;
           pobjMain->FreeLength(); // free memory used by GetLength
           
           return posdirOutput;
      }

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

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

        On 17/06/2004 at 19:25, xxxxxxxx wrote:

        First, there seems to be a typo in the code: UniformTonatural should be UniformTonatural.
        How big are the errors? For extreme splines with few points and long tangents, numerical errors might make the calculations slightly off. I use the UniformTonatural() function in MSA and it seems to work.

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

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

          On 17/06/2004 at 21:33, xxxxxxxx wrote:

          Hallo. Thx for answer.
          The errors are zero in the average but...

          I have 2 objects and both moved with the same speed. I look through the camera on the 1st object. 1st object have as way (spline object) a qubic spline object with some curves, but most part of spline is straight. 2nd object have a "linear" straight spline parallel to the 1st way.    When both objects move, then you can see, that 1st object on straight parts of his way chaotic accelerate/ deaccelerate relative to 2nd object and this looking bad.

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

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

            On 17/06/2004 at 22:27, xxxxxxxx wrote:

            ... if you wish, so i can send the video, where you can see the problem (4 MB).

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