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
    • Recent
    • Tags
    • Users
    • Login

    The perpendicular plane to a spline

    Scheduled Pinned Locked Moved SDK Help
    17 Posts 0 Posters 1.4k 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

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

      On 06/06/2010 at 10:49, xxxxxxxx wrote:

      Would this help?

      http://en.wikipedia.org/wiki/Helix

      This at least provides some formulas.

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

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

        On 06/06/2010 at 10:53, xxxxxxxx wrote:

        I had already been there, emberintherain. And, unfortunately, it doesn't help me much. I know how to create an helix along a line. Not along an arbitrary spline 😞

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

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

          On 06/06/2010 at 11:12, xxxxxxxx wrote:

          My theoretical go at it would be to describe a regular circle (local sin x , cos y) around the
          z direction ( of a matrix at spline position).
          Iterating the position of that matrix along the spline while
          calculating the circle would then describe a helix along the spline.

          (The movement along the spline corresponding to the "t" in that Helix formula)

          Cheers
          Lennart

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

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

            On 06/06/2010 at 15:47, xxxxxxxx wrote:

            That sounds logic and I can see it in my mind.
            The problem is how to make sure the "circle" gets mapped perpendicularly to the points along the spline.
            The matrix of the spline gives me just that, the matrix of the position/rotation/scale of the spline object, not the matrix of the points along the spline.

            Rui Batista

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

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

              On 06/06/2010 at 16:18, xxxxxxxx wrote:

              You need to build a matrix. The position is given by the spline point position.
              The rotation you build from the spline point position and the tangent position.
              The GetSplineTangent(x,0) returns a position in space tangential to the
              spline point position at distance x. (It doesn't give a angle).

              Using VectorToHPB(splinepoint - tangentpoint) will give you the
              basic rotation (skipping up vector to start with)

              So you basically build a AlignToSpline function moving a tangential
              matrix (instead of an object).

              This matrix is what you have as a base for the circle calculation.

              Cheers
              Lennart

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

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

                On 06/06/2010 at 16:35, xxxxxxxx wrote:

                Mmmmm, ok, I will give it a try. Thank you Lennart.

                Rui Batista

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

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

                  On 06/06/2010 at 18:35, xxxxxxxx wrote:

                  So, this is a snippet of my code:

                    
                  x=spline1->UniformToNatural(float(f)/(n_points-1));   
                  pos=spline1->GetSplinePoint(x,0);   
                  tang=spline1->GetSplineTangent(x,0);   
                    
                  r1=50*sin(31.415*f); // just for testing   
                  r2=50*cos(31.415*f); // just for testing   
                    
                  hpb=VectorToHPB(vnorm(pos-tang));   
                    
                  new_mat = new(Matrix);   
                  new_mat->SetV0(pos);   
                  new_mat->SetRotHPB(hpb);   
                    
                  vec = vector(r1,r2, 0.0);   
                  new_vec = new_mat->GetMulP(vec);   
                  

                  Should this be it? Its not working as I expected 😞

                  Rui Batista

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

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

                    On 06/06/2010 at 19:00, xxxxxxxx wrote:

                    See if this rude set up might help.

                      
                    // Put COFFEE Tag on an object to circle the spline   
                    // Add a point spline in link field.   
                      
                    GetFirstTag(obj,type)   
                    {   
                    var tag = obj->GetFirstTag();   
                    while (tag){   
                    if (tag->GetType() == type) return tag;   
                    tag = tag->GetNext();   
                    }   
                    return NULL;   
                    }   
                      
                    main(doc,op)   
                    {   
                    var ctag = GetFirstTag(op,Tcoffeeexpression);   
                    var udpos = ctag#ID_USERDATA:1;   
                    var spline = ctag#ID_USERDATA:2;   
                      
                        spline->InitLength(0);   
                    var spos = spline->GetSplinePoint(spline->UniformToNatural(udpos),0);   
                    var tpos = spline->GetSplineTangent(spline->UniformToNatural(udpos),0);   
                    var srot = VectorToHPB(tpos);   
                    var revs = 20; // revs along spline   
                    var mym = new(Matrix);   
                        mym->SetRotHPB(srot+vector(0,0,udpos*2*PI*revs));   
                        mym->SetV0(spos);   
                        mym = spline->GetMg()->GetMulM(mym);   
                    op->SetMg(mym);   
                    }   
                    

                    R11.5 example scene

                    Cheers
                    Lennart

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

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

                      On 06/06/2010 at 19:41, xxxxxxxx wrote:

                      It helped me a lot but its still not working the way I want it to 😞
                      I want to adjust the points of a spline so that it spirals around another spline.
                      If its not asking you too much, could you take a look at what I have come up so far?
                      Pay no attention to the User Data parameters of the COFFEE tag. For now, only the Spline, Number of Points and Radius are working.
                      Thank you very much in advance.

                      Rui Batista

                      Spiral file

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

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

                        On 07/06/2010 at 08:10, xxxxxxxx wrote:

                        Hey guys. You must not add hpb rotations just like so 😜
                        Its better generate a local rotation matrix and multiply it to the right of the tangent plane matrix.

                        Here is a piece of code which works pretty well in Ruis scene:

                          
                             var m_spiral = new(Matrix);   
                             m_spiral->SetRotHPB(vector(0,0,t*2*PI*10));   
                          
                             var hpb=VectorToHPB(tang);   
                             var new_mat = new(Matrix);   
                             new_mat->SetRotHPB(hpb);   
                             new_mat->SetV0(pos);   
                             new_mat=new_mat->GetMulM(m_spiral);   
                             new_mat=spline1->GetMg()->GetMulM(new_mat);   
                          
                             var vec = vector(0.0,radii,0.0);   
                             var new_vec = new_mat->GetMulP(vec);   
                        
                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          Helper
                          last edited by

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

                          On 07/06/2010 at 13:51, xxxxxxxx wrote:

                          Thanks Michael, that shaved a few lines off in my set up.
                          Making a little Spiral Gadget here 🙂

                          Rui, did you get it working now?

                          Cheers
                          Lennart

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

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

                            On 07/06/2010 at 18:40, xxxxxxxx wrote:

                            Yes, its working fine now. Well, I still have to add a few more options but the main part is already working.
                            Thank you all for the help 🙂

                            Rui Batista

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