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

    Points equal but distance is not larger or less?

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