sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Find vector closest to X_AXIS

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 2 Posters 147 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.
    • thomthomT Offline
      thomthom
      last edited by

      With a given set of various vectors, how do you determine which one is the one most parallel to another, say the X_AXIS?

      Thomas Thomassen β€” SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • A Offline
        avariant
        last edited by

        take the dot product of each vector, normalized, with the vector you are comparing against, normalized.

        
        how_close = vector_a.normalize().dot( comparison_axis )
        how_close_b = vector_b.normalize().dot( comparison_axis )
        
        

        the normalize is important because they all need to be the same length for this kind of comparison.

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          Does the direction of the vector matter then?

          Thomas Thomassen β€” SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • A Offline
            avariant
            last edited by

            Oops sorry. Meant to tack that on.

            dot product = 1 means parallel and in the same direction
            dot product = -1 means parallel and in the opposite direction.

            So if direction matters, look for closest to 1. If it doesn't, use the absolute value.

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              Great! Thank you very much! πŸ‘ πŸ‘

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              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