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

    Question about coordinate problem at zero

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 4 Posters 238 Views 4 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.
    • PixeroP Offline
      Pixero
      last edited by

      Hi!

      I have a question that is not directly about SketchUp or Ruby but still a problem...

      I need coordinate values that are positive so I use abs(x) to get it from negative coordinates and that works fine.
      The problem I have is that when the coordinates are precisely at 0, (x==0 || y==0 || z==0) the rest of the math doesn't work.
      My experiments with it havent worked so far.
      For example I've tried with setting it to a very small value if the coordinate is exactly 0.
      I'm unsure what to Google for to find any info.

      Does anyone know how these things are usually solved?

      (Sorry for beeing a bit cryptic and a bit off topic.) πŸ˜•

      1 Reply Last reply Reply Quote 0
      • dukejazzD Offline
        dukejazz
        last edited by

        aspect ratio of some objects won't center on [0,0,0] with snap
        usealy two coordinate ok one not
        try turning off snap

        it still dosn't work
        you might need more precision.
        make sure you object is a group
        it gives 2x precision
        but don't expode complety if your group object smaller .001, it will disapear from view
        hit undo if it doses.

        here a plugin that will shape a object to a better precision
        scaleGroupFloat_dj Ver 1.6.5
        Copyright Feb 15, 2013
        DukeJazz: by James Cochran
        http://sketchucation.com/forums/viewtopic.php?f=323&t=45254

        Info: Best high precision 3d scale and move tool yet.

        add zoro to numbers of lenght
        1.0000001

        1 Reply Last reply Reply Quote 0
        • jolranJ Offline
          jolran
          last edited by

          Hej.

          Isent abs kind of slow ?
          I used it before for something for the same reason as you, but got very slow code πŸ˜• .

          A hack would be to round of to around 0,001 or something. Might avoid floating point precision errors as well.

          Edit: Sorry did not read you post thourougly.

          @unknownuser said:

          For example I've tried with setting it to a very small value if the coordinate is exactly 0.

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

            Difficult to say what to do without knowing what the purpose of the code is. Sounds like 0 is an edge case for you - if you cannot make the calculation work with 0, then maybe you need to make a special processing case for when you're values are 0.

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

            1 Reply Last reply Reply Quote 0
            • PixeroP Offline
              Pixero
              last edited by

              Thanks for your replies.
              This isnt directly connected to SU and is from a C++ project of mine.
              However I solved it.
              Turned out I needed a custom fmod function since the one built into C really is a remainder function and not a modulo function. πŸ€“

              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