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

    Drawing a parallel line

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 614 Views 3 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.
    • S Offline
      spireup
      last edited by

      Hi

      I want to be able to supply a line and a width to a method and have the method draw a rectangle based on that line and a parallel line that width apart.

      I want to use this for drawing the footprints of walls that may be sloped or paths on sloped terrain etc.

      My question is what is the precise transformation required to get this second parallel line? Im considering working either with points perhaps using the offset method or with vectors. Either way I need to figure out the right transformation.

      One thing Im thinking is that a perpendicular line to the original line of length 'width' would be a useful vector. However when I try and calculate that I cant figure out which plane Im meant to rotate in to get it(is it multiple planes)!

      One problem with perpendicular lines is i can see that there are at least two perpendicular lines to any one line ignoring direction.

      thanks heaps for any help!

      Paul

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        You should be able to steal code from the box.rb example, since it creates a rectangle before it pushpulls it into a box.

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          If you are drawing these double lines on a 'surface' then picked-point at point1 can be used to return the best face below it - get the axis=face.normal...
          If it's not on any face or you want it flat then axis=Z_AXIS
          Then next picked_point point2 needs to be on that face, so get it's initial value and then use
          point2=point2.project_to_plane(face.plane)
          or if it's to be 'flat' use point2.z=point1.z instead so it's level with point1...
          This gives you the first edge
          edge12=entities.add_line(point1,point2)
          To make it's offset 'clone'...
          Assuming ' width' is the offset required.
          point3=point1.offset(edge12.line[1],width)
          rotate it into place...
          tr=Geom::Transformation.rotation(point1,axis,90.degrees) point3.transform!(tr)
          get the other end point
          point4=point3.offset(edge12.line[1],edge12.length)
          and then draw the offset edge
          edge34=entities.add_line(point3,point4)
          πŸ€“

          TIG

          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