JSCAD User Group
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    using vector operations (subtract)

    Scheduled Pinned Locked Moved Development Discussions
    4 Posts 2 Posters 908 Views 1 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.
    • gilboonetG Offline
      gilboonet
      last edited by

      Hello,
      yesterday I needed to modify my 2 axis slicer script for it to be compatible with latest v2 version. The error shown into web console was about subtract, so I first thought there was a problem with CSG subtract and discarded the code using it, but indeed it was vec3.subtract that I'm using as a replacement of now deprecated minus(). I replaced it with

      //d = vec3.subtract(b[1], b[0]);
      d = [b[1][0]-b[0][0], b[1][1]-b[0][1], b[1][2]-b[0][2]];
      

      but isn't there anymore a way to use vector operations like subtract() because it helps keeping the code easy to read.

      z3devZ 2 Replies Last reply Reply Quote 0
      • z3devZ Offline
        z3dev @gilboonet
        last edited by

        @gilboonet you hit one of the differences in the maths.

        Change

        subtract(a, b) to subtract(a, a, b)

        If you need to then create a new vec.

        subtract(vec3.create(), a, b)

        gilboonetG 1 Reply Last reply Reply Quote 0
        • z3devZ Offline
          z3dev @gilboonet
          last edited by

          You can find the API documentation at www.Openjscad.xyz/docs/

          There should be some simple examples as well.

          1 Reply Last reply Reply Quote 0
          • gilboonetG Offline
            gilboonet @z3dev
            last edited by

            @z3dev Thanks, I will change to subtract(a, a, b)

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            Powered by NodeBB | Contributors