sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Points equal but distance is not larger or less?

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 320 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

      ` pt1 = Geom::Point3d.new(-1473.34, -1459.58, 803.961)
      pt3 = Geom::Point3d.new(-1473.34, -1459.58, 803.96)

      pt1 == pt3
      true

      pt1.distance(pt3)
      0.000999999999976353

      pt1.distance(pt3) > 0.001
      false

      pt1.distance(pt3) < 0.001
      false`

      ❓ ❓

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

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

        Ah! Because it was comparing Length classes - which has SU's tolerance builtin.

        This works as expected:
        pt1.distance(pt3).to_f < 0.001 true pt1.distance(pt3).to_f > 0.001 false

        I wanted to compare to point with a higher tolerance than SU's tolerance.
        So either I must convert to float - yet another operation, or I do:
        pt1.distance(pt3) <= 0.002

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

        1 Reply Last reply Reply Quote 0
        • AdamBA Offline
          AdamB
          last edited by

          Sure you know this, but if you're comparing distances rather than interested in the absolute distance, the fastest way will be to project a vector onto itself using scalar product.

          p1.dot(p1) < p2.dot(p2)

          Adam

          Developer of LightUp Click for website

          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