sketchucation logo sketchucation
    • Login
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Points equal but distance is not larger or less?

    scheduled pinned locked moved Developers' Forum
    3 Posts 2 Posters 305 Views 2 Watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • 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

      one-reply-to-this-post last-reply-time 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

        one-reply-to-this-post last-reply-time 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

          one-reply-to-this-post last-reply-time 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