sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    New translate request?

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 106 Views 2 Watching
    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.
    • T Offline
      tomot
      last edited by

      I believe Didier devised this brilliant bit of code, I have been using it mainly because the new point it creates are not static and works in any 3d orientation.

      # creates a new point from p1 in the direction of p2-p3 with length d
          # params are Point3d, 2 vertices, a length, returns a Point3d
          def translate(p1, p2, p3, d)
              v = p3 - p2
              v.length = d
              trans = Geom;;Transformation.translation(v)
              return p1.transform(trans)
          end
      

      I'm not skilled enough in Ruby to develop a similar new bit of code. So I'm hoping someone here can help me. I would like this new bit of code help me find a point p3? given the "dotted" distance which lies outside and inline with p1 and p2 The attached pic. illustrates what the current code does, and what I'm requesting.

      Tia!


      translate.jpg

      [my plugins](http://thingsvirtual.blogspot.ca/)
      tomot

      1 Reply Last reply Reply Quote 0
      • fredo6F Offline
        fredo6
        last edited by

        @tomot said:

        So I'm hoping someone here can help me. I would like this new bit of code help me find a point p3? given the "dotted" distance which lies outside and inline with p1 and p2 The attached pic. illustrates what the current code does, and what I'm requesting.

        Tia!

        Assuming the dotted distance is < dd> and you name p3? by p4, just use

        p4 = p2.offset p3.vector_to(p2), dd
        

        The line oriented vector is p3.vector_to(p2), and you just offset p2 by the distance dd.

        Fredo

        1 Reply Last reply Reply Quote 0
        • T Offline
          tomot
          last edited by

          @unknownuser said:

          Assuming the dotted distance is < dd> and you name p3? by p4, just use

          p4 = p2.offset p3.vector_to(p2), dd
          

          The line oriented vector is p3.vector_to(p2), and you just offset p2 by the distance dd.
          Fredo

          Thanks Fredo6: I see my use of English has failed me again 😳 My p3? would actually become the new location of p3 similar to the original code starting with a new name to distinguish it it for other code snippets hence the first line would start something like this

          def translate_extend(p1, p2, p3, d)
          

          followed by the technical stuff, and so I can reuse it again in other places where required in any other script.

          [my plugins](http://thingsvirtual.blogspot.ca/)
          tomot

          1 Reply Last reply Reply Quote 0
          • fredo6F Offline
            fredo6
            last edited by

            Then use

            p3 = p2.offset p2.vector_to(p1), d
            

            This gives the point p3, which at distance d of P2 in the direction of p1

            Fredo

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement